示例#1
0
文件: manifest_test.go 项目: nsnt/cli
func TestParsingManifestWithNulls(t *testing.T) {
	_, errs := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"applications": []interface{}{
			map[string]interface{}{
				"buildpack":  nil,
				"disk_quota": nil,
				"domain":     nil,
				"host":       nil,
				"name":       nil,
				"path":       nil,
				"stack":      nil,
				"memory":     nil,
				"instances":  nil,
				"timeout":    nil,
				"no-route":   nil,
				"services":   nil,
				"env":        nil,
			},
		},
	}))

	assert.Error(t, errs)
	errorSlice := strings.Split(errs.Error(), "\n")
	manifestKeys := []string{"buildpack", "disk_quota", "domain", "host", "name", "path", "stack",
		"memory", "instances", "timeout", "no-route", "services", "env"}

	for _, key := range manifestKeys {
		testassert.SliceContains(t, errorSlice, testassert.Lines{{key, "not be null"}})
	}
}
示例#2
0
文件: manifest_test.go 项目: nsnt/cli
func TestParsingEmptyManifestDoesNotSetCommand(t *testing.T) {
	m, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"applications": []interface{}{
			map[string]interface{}{},
		},
	}))

	assert.NoError(t, err)
	assert.False(t, m.Applications[0].Has("command"))
}
示例#3
0
func testManifestWithAbsolutePathOnWindows() {
	m, errs := manifest.NewManifest(`C:\some\path`, generic.NewMap(map[interface{}]interface{}{
		"applications": []interface{}{
			map[interface{}]interface{}{
				"path": `C:\another\path`,
			},
		},
	}))

	Expect(errs).To(BeEmpty())
	Expect(*m.Applications[0].Path).To(Equal(`C:\another\path`))
}
示例#4
0
func testManifestWithAbsolutePathOnPosix() {
	m, errs := manifest.NewManifest("/some/path", generic.NewMap(map[interface{}]interface{}{
		"applications": []interface{}{
			map[interface{}]interface{}{
				"path": "/another/path-segment",
			},
		},
	}))

	Expect(errs).To(BeEmpty())
	Expect(*m.Applications[0].Path).To(Equal("/another/path-segment"))
}
示例#5
0
文件: manifest_test.go 项目: nsnt/cli
func TestParsingManifestWithNullCommand(t *testing.T) {
	m, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"applications": []interface{}{
			map[string]interface{}{
				"command": nil,
			},
		},
	}))

	assert.NoError(t, err)
	assert.Equal(t, m.Applications[0].Get("command"), "")
}
示例#6
0
文件: manifest_test.go 项目: nsnt/cli
func TestParsingManifestWithTimeoutSetsHealthCheckTimeout(t *testing.T) {
	m, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"applications": []interface{}{
			map[string]interface{}{
				"name":    "bitcoin-miner",
				"timeout": "360",
			},
		},
	}))

	assert.NoError(t, err)
	assert.Equal(t, m.Applications[0].Get("health_check_timeout"), 360)
	assert.False(t, m.Applications[0].Has("timeout"))
}
示例#7
0
文件: manifest_test.go 项目: nsnt/cli
func TestManifestWithInvalidMemory(t *testing.T) {
	_, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"instances": "3",
		"memory":    "512",
		"applications": []interface{}{
			map[string]interface{}{
				"name": "bitcoin-miner",
			},
		},
	}))

	assert.Error(t, err)
	assert.Contains(t, err.Error(), "memory")
}
示例#8
0
文件: manifest_test.go 项目: nsnt/cli
func TestParsingManifestWithPropertiesReturnsErrors(t *testing.T) {
	_, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"applications": []interface{}{
			map[string]interface{}{
				"env": map[string]interface{}{
					"bar": "many-${foo}-are-cool",
				},
			},
		},
	}))

	assert.Error(t, err)
	assert.Contains(t, err.Error(), "Properties are not supported. Found property '${foo}'")
}
示例#9
0
文件: manifest_test.go 项目: nsnt/cli
func TestParsingManifestWithEmptyEnvVarIsInvalid(t *testing.T) {
	_, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"env": map[string]interface{}{
			"bar": nil,
		},
		"applications": []interface{}{
			map[string]interface{}{
				"name": "bad app",
			},
		},
	}))

	assert.Error(t, err)
	assert.Contains(t, err.Error(), "env var 'bar' should not be null")
}
示例#10
0
func TestManifestWithGlobalAndAppSpecificProperties(t *testing.T) {
	m, err := manifest.NewManifest(generic.NewMap(map[string]interface{}{
		"instances": "3",
		"memory":    "512M",
		"applications": []interface{}{
			map[string]interface{}{
				"name": "bitcoin-miner",
			},
		},
	}))
	assert.NoError(t, err)

	apps := m.Applications
	assert.Equal(t, apps[0].Get("instances"), 3)
	assert.Equal(t, apps[0].Get("memory").(uint64), uint64(512))
}
示例#11
0
				"path": `C:\another\path`,
			},
		},
	}))

	Expect(errs).To(BeEmpty())
	Expect(*m.Applications[0].Path).To(Equal(`C:\another\path`))
}

var _ = Describe("Testing with ginkgo", func() {
	It("TestManifestWithGlobalAndAppSpecificProperties", func() {
		m, errs := manifest.NewManifest("/some/path", generic.NewMap(map[interface{}]interface{}{
			"instances": "3",
			"memory":    "512M",
			"applications": []interface{}{
				map[interface{}]interface{}{
					"name":     "bitcoin-miner",
					"no-route": true,
				},
			},
		}))

		Expect(errs).To(BeEmpty())

		apps := m.Applications
		Expect(*apps[0].InstanceCount).To(Equal(3))
		Expect(*apps[0].Memory).To(Equal(uint64(512)))
		Expect(*apps[0].NoRoute).To(BeTrue())
	})

	It("TestManifestWithInvalidMemory", func() {
		_, errs := manifest.NewManifest("/some/path", generic.NewMap(map[interface{}]interface{}{