func TestCCCAddRemoveConfig(t *testing.T) { tmpHome, savedHome := createCCCTmpHome(t) defer os.RemoveAll(tmpHome) defer os.Setenv("HOME", savedHome) var conf cutils.UpdateClientConfig invalidURL := "" validURL := "app#http://containerops/official/duc.rpm" // 'add' err := conf.Add(invalidURL) assert.Equal(t, err, cutils.ErrorsUCInvalidURL) err = conf.Add(validURL) assert.Nil(t, err, "Failed to add repository") err = conf.Add(validURL) assert.Equal(t, err, cutils.ErrorsUCRepoExist) // 'remove' err = conf.Remove(validURL) assert.Nil(t, err, "Failed to remove repository") err = conf.Remove(validURL) assert.Equal(t, err, cutils.ErrorsUCRepoNotExist) }
} fmt.Printf("Success in adding %s.\n", url) return nil }, } var removeCommand = cli.Command{ Name: "remove", Usage: "remove a repository url", Action: func(context *cli.Context) error { var ucc cutils.UpdateClientConfig url := context.Args().Get(0) if err := ucc.Remove(url); err != nil { fmt.Println(err) return err } fmt.Printf("Success in removing %s.\n", url) return nil }, } var listCommand = cli.Command{ Name: "list", Usage: "list the saved repositories or appliances of a certain repository", Action: func(context *cli.Context) error { var ucc cutils.UpdateClientConfig