コード例 #1
0
// TestCCCInitConfig tests the Init function
func TestCCCInitConfig(t *testing.T) {
	tmpHome, savedHome := createCCCTmpHome(t)
	defer os.RemoveAll(tmpHome)
	defer os.Setenv("HOME", savedHome)

	var conf cutils.UpdateClientConfig
	err := conf.Init()
	assert.Nil(t, err, "Fail to init config")
}
コード例 #2
0
// TestCCCLoadConfig tests the testdata/home/.dockyard/repo.json file
func TestCCCLoadConfig(t *testing.T) {
	_, path, _, _ := runtime.Caller(0)
	testHome := "/testdata/home"
	savedHome := os.Getenv("HOME")
	defer os.Setenv("HOME", savedHome)
	os.Setenv("HOME", filepath.Join(filepath.Dir(path), testHome))

	var conf cutils.UpdateClientConfig
	err := conf.Load()
	assert.Nil(t, err, "Fail to load config")
	assert.Equal(t, conf.DefaultServer, "containerops.me", "Fail to load 'DefaultServer'")
}
コード例 #3
0
ファイル: client.go プロジェクト: pombredanne/dockyard
		initCommand,
		addCommand,
		removeCommand,
		listCommand,
		pushCommand,
		pullCommand,
		deleteCommand,
		decryptCommand,
	},
}

var initCommand = cli.Command{
	Name:  "init",
	Usage: "initiate default setting",
	Action: func(context *cli.Context) error {
		var ucc cutils.UpdateClientConfig

		if err := ucc.Init(); err != nil {
			fmt.Println(err)
			return err
		}

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

var addCommand = cli.Command{
	Name:  "add",
	Usage: "add a repository url",
コード例 #4
0
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)
}