Пример #1
0
func newValidLRPKey() models.DesiredLRPKey {
	return models.NewDesiredLRPKey("some-guid", "domain", "log-guid")
}
Пример #2
0
var _ = Describe("DesiredLRPKey", func() {
	const guid = "valid-guid"
	const domain = "valid-domain"
	const log = "valid-log-guid"

	DescribeTable("Validation",
		func(key models.DesiredLRPKey, expectedErr string) {
			err := key.Validate()
			if expectedErr == "" {
				Expect(err).NotTo(HaveOccurred())
			} else {
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring(expectedErr))
			}
		},
		Entry("valid key", models.NewDesiredLRPKey(guid, domain, log), ""),
		Entry("blank process guid", models.NewDesiredLRPKey("", domain, log), "process_guid"),
		Entry("blank domain", models.NewDesiredLRPKey(guid, "", log), "domain"),
		Entry("blank log guid is valid", models.NewDesiredLRPKey(guid, domain, ""), ""),
	)
	Context("process_guid only contains `A-Z`, `a-z`, `0-9`, `-`, and `_`", func() {
		validGuids := []string{"a", "A", "0", "-", "_", "-aaaa", "_-aaa", "09a87aaa-_aASKDn"}
		for _, validGuid := range validGuids {
			func(validGuid string) {
				It(fmt.Sprintf("'%s' is a valid process_guid", validGuid), func() {
					key := models.NewDesiredLRPKey(validGuid, domain, log)
					err := key.Validate()
					Expect(err).NotTo(HaveOccurred())
				})
			}(validGuid)
		}