package plugin_test import ( "slices" "strings" "testing" "tangled.org/guid.foo/simmer/plugin" ) func TestEachPluginsDirectoryIsNamedForItsRepository(t *testing.T) { dirs, err := plugin.Dirs("/plugins", []string{ "ssh://git@forge.example/person/personal.git", "git@forge.example:person/docs.git", "https://forge.example/person/shop/", }) if err != nil { t.Fatal(err) } want := []string{"/plugins/personal", "/plugins/docs", "/plugins/shop"} if !slices.Equal(dirs, want) { t.Errorf("dirs = %q, want %q", dirs, want) } } func TestTwoPluginsWithOneNameConflict(t *testing.T) { _, err := plugin.Dirs("/plugins", []string{ "git@forge.example:person/personal.git", "git@elsewhere.example:other/personal.git", }) if err == nil || !strings.Contains(err.Error(), "personal") { t.Errorf("Dirs answered %v, want an error that names personal", err) } }