|
|
|
@ -131,6 +131,39 @@ func TestRepoAdd(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRepoAddCheckLegalName(t *testing.T) {
|
|
|
|
|
ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*")
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
defer ts.Stop()
|
|
|
|
|
defer resetEnv()()
|
|
|
|
|
|
|
|
|
|
const testRepoName = "test-hub/test-name"
|
|
|
|
|
|
|
|
|
|
rootDir := ensure.TempDir(t)
|
|
|
|
|
repoFile := filepath.Join(ensure.TempDir(t), "repositories.yaml")
|
|
|
|
|
|
|
|
|
|
o := &repoAddOptions{
|
|
|
|
|
name: testRepoName,
|
|
|
|
|
url: ts.URL(),
|
|
|
|
|
forceUpdate: false,
|
|
|
|
|
deprecatedNoUpdate: true,
|
|
|
|
|
repoFile: repoFile,
|
|
|
|
|
}
|
|
|
|
|
os.Setenv(xdg.CacheHomeEnvVar, rootDir)
|
|
|
|
|
|
|
|
|
|
wantErrorMsg := fmt.Sprintf("repository name (%s) contains '/', please specify a different name without '/'", testRepoName)
|
|
|
|
|
|
|
|
|
|
if err := o.run(ioutil.Discard); err != nil {
|
|
|
|
|
if wantErrorMsg != err.Error() {
|
|
|
|
|
t.Fatalf("Actual error %s, not equal to expected error %s", err, wantErrorMsg)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
t.Fatalf("expect reported an error.")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRepoAddConcurrentGoRoutines(t *testing.T) {
|
|
|
|
|
const testName = "test-name"
|
|
|
|
|
repoFile := filepath.Join(ensure.TempDir(t), "repositories.yaml")
|
|
|
|
|