45 lines
849 B
Go
45 lines
849 B
Go
// Copyright (c) 2024 Joshua Rich <joshua.rich@gmail.com>
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
//nolint:paralleltest
|
|
package registry
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func Test_checkPath(t *testing.T) {
|
|
type args struct {
|
|
path string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "exists",
|
|
args: args{path: t.TempDir()},
|
|
},
|
|
{
|
|
name: "does not exist",
|
|
args: args{path: filepath.Join(t.TempDir(), "notexists")},
|
|
},
|
|
{
|
|
name: "unwriteable",
|
|
args: args{path: "/notexists"},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if err := checkPath(tt.args.path); (err != nil) != tt.wantErr {
|
|
t.Errorf("checkPath() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|