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)
}
示例#2
0
		}

		fmt.Println("Success in initiating Dockyard Updater Client configuration.")
		return nil
	},
}

var addCommand = cli.Command{
	Name:  "add",
	Usage: "add a repository url",

	Action: func(context *cli.Context) error {
		var ucc cutils.UpdateClientConfig

		url := context.Args().Get(0)
		if err := ucc.Add(url); err != nil {
			fmt.Println(err)
			return err
		}

		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