Exemplo n.º 1
0
func TestFilterConfigWeb(t *testing.T) {
	c := NewConfig("", "test/Simple/captain.yml", false)
	assert.Equal(t, 2, len(c.GetApps()), "Should return 2 apps")

	c.FilterConfig("web")
	assert.Equal(t, 1, len(c.GetApps()), "Should return 1 app")
	assert.Equal(t, "Dockerfile", c.GetApp("web").Build, "Should return web Build field")
}
Exemplo n.º 2
0
func TestFilterConfigEmpty(t *testing.T) {
	c := NewConfig("", "test/Simple/captain.yml", false)
	assert.Equal(t, 2, len(c.GetApps()), "Should return 2 apps")

	res := c.FilterConfig("")
	assert.True(t, res, "Should return true")
	assert.Equal(t, 2, len(c.GetApps()), "Should return 2 apps")
}
Exemplo n.º 3
0
func TestFilterConfigNonExistent(t *testing.T) {
	c := NewConfig("", "test/Simple/captain.yml", false)
	assert.Equal(t, 2, len(c.GetApps()), "Should return 2 apps")

	res := c.FilterConfig("nonexistent")
	assert.False(t, res, "Should return false")
	assert.Equal(t, 0, len(c.GetApps()), "Should return 0 apps")
}
Exemplo n.º 4
0
func TestTagNonexistingImage(t *testing.T) {
	app := App{Image: "golang"}
	res := tagImage(app, "nonexist", "testing")
	expected := errors.New("no such image")
	assert.Equal(t, expected, res, "Docker tag should return an error")
	println()
}
Exemplo n.º 5
0
func TestGitIsDirty(t *testing.T) {
	assert.Equal(t, false, isDirty(), "Git should not have local changes")
}
Exemplo n.º 6
0
func TestGitGetBranch(t *testing.T) {
	assert.Equal(t, "master", getBranch(), "Git branch should be master")
}
Exemplo n.º 7
0
func TestExecute(t *testing.T) {
	res := execute("echo", "testing")
	assert.Equal(t, nil, res, "it should execute without errors")
}
Exemplo n.º 8
0
func TestOnelinerTrimmed(t *testing.T) {
	res, _ := oneliner("echo", "testing with spaces  ")
	assert.Equal(t, "testing with spaces", res, "it should return the trimmed result")
}
Exemplo n.º 9
0
func TestGitGetBranchAllBranches(t *testing.T) {
	assert.Equal(t, []string{"master"}, getBranches(true), "Git branch should be master")
}
Exemplo n.º 10
0
func TestGitGetRevisionFullSha(t *testing.T) {
	assert.Equal(t, 40, len(getRevision(true)), "Git revision should have a length of 40 chars")
}
Exemplo n.º 11
0
func TestImageExist(t *testing.T) {
	app := App{Image: "golang"}
	exist := imageExist(app, "1.4")
	assert.Equal(t, true, exist, "Docker image golang:1.4 should exist")
}
Exemplo n.º 12
0
func TestConfigFiles(t *testing.T) {
	options.config = "captain.yml"
	c := configFile(options)
	sl := "captain.yml"
	assert.Equal(t, sl, c, "Should return possible config files")
}
Exemplo n.º 13
0
func TestGetApp(t *testing.T) {
	options.config = "test/Simple/captain.yml"
	c := NewConfig(options, false)
	app := c.GetApp("web")
	assert.Equal(t, "harbur/test_web", app.Image, "Should return web image")
}
Exemplo n.º 14
0
func TestGitIsGit(t *testing.T) {
	assert.Equal(t, true, isGit(), "There should be a git repository")
}
Exemplo n.º 15
0
func TestImageDoesNotExist(t *testing.T) {
	app := App{Image: "golang"}
	exist := imageExist(app, "nonexist")
	assert.Equal(t, false, exist, "Docker image golang:nonexist should not exist")
}
Exemplo n.º 16
0
func TestGitGetRevision(t *testing.T) {
	assert.Equal(t, 7, len(getRevision()), "Git revision should have length 7 chars")
}
Exemplo n.º 17
0
func TestColorCodes(t *testing.T) {
	assert.Equal(t, "\x1b[32mhello\x1b[0m", colorInfo("hello"), "they should be equal")
	assert.Equal(t, "\x1b[33mhello\x1b[0m", colorWarn("hello"), "they should be equal")
	assert.Equal(t, "\x1b[31mhello\x1b[0m", colorErr("hello"), "they should be equal")
}