Files
containerd/pkg/shim/util_abstract_test.go
T
Paweł Gronowski 31c6307262 pkg/shim: Add unit tests
Currently the tests fail on Linux:

```
--- FAIL: TestNewSocket (0.00s)
    --- FAIL: TestNewSocket/socket_in_nested_directory (0.00s)
        util_unix_test.go:42: NewSocket failed: mkdir failed for /tmp/shim-test-1791693890/a/b/test.sock: mkdir /tmp/shim-test-1791693890/a/b: permission denied
FAIL
FAIL	github.com/containerd/containerd/v2/pkg/shim	0.004s
FAIL
```

This is fixed by the next commit.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-03-13 10:20:01 +01:00

42 lines
1.0 KiB
Go

//go:build !windows && !darwin
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package shim
import (
"net"
"testing"
"time"
)
func TestNewSocketAbstract(t *testing.T) {
address := "@shim-test-abstract"
l, err := NewSocket(address)
if err != nil {
t.Fatalf("NewSocket failed: %v", err)
}
t.Cleanup(func() { l.Close() })
conn, err := net.DialTimeout("unix", socket(address).path(), time.Second)
if err != nil {
t.Fatalf("failed to connect to socket: %v", err)
}
conn.Close()
}