Пример #1
0
func Resource(resource atc.ResourceConfig, groups atc.GroupConfigs, dbResource db.SavedResource, showCheckError bool) atc.Resource {
	generator := rata.NewRequestGenerator("", web.Routes)

	req, err := generator.CreateRequest(
		web.GetResource,
		rata.Params{"resource": resource.Name, "pipeline_name": dbResource.PipelineName},
		nil,
	)
	if err != nil {
		panic("failed to generate url: " + err.Error())
	}

	groupNames := []string{}
	for _, group := range groups {
		for _, name := range group.Resources {
			if name == resource.Name {
				groupNames = append(groupNames, group.Name)
			}
		}
	}

	var checkErrString string
	if dbResource.CheckError != nil && showCheckError {
		checkErrString = dbResource.CheckError.Error()
	}

	return atc.Resource{
		Name:   resource.Name,
		Type:   resource.Type,
		Groups: groupNames,
		URL:    req.URL.String(),

		Paused: dbResource.Paused,

		FailingToCheck: dbResource.FailingToCheck(),
		CheckError:     checkErrString,
	}
}
Пример #2
0
			}

			for _, state := range states {
				build := db.Build{
					Status: state,
				}
				Ω(build.Abortable()).Should(BeFalse())
			}
		})
	})
})

var _ = Describe("Resource", func() {
	Describe("FailingToCheck", func() {
		It("returns true if there is a check error", func() {
			resource := db.SavedResource{
				CheckError: errors.New("nope"),
			}

			Ω(resource.FailingToCheck()).Should(BeTrue())
		})

		It("returns false if there is no check error", func() {
			resource := db.SavedResource{
				CheckError: nil,
			}
			Ω(resource.FailingToCheck()).Should(BeFalse())
		})
	})
})
Пример #3
0
			}

			for _, state := range states {
				build := db.Build{
					Status: state,
				}
				Expect(build.Abortable()).To(BeFalse())
			}
		})
	})
})

var _ = Describe("Resource", func() {
	Describe("FailingToCheck", func() {
		It("returns true if there is a check error", func() {
			resource := db.SavedResource{
				CheckError: errors.New("nope"),
			}

			Expect(resource.FailingToCheck()).To(BeTrue())
		})

		It("returns false if there is no check error", func() {
			resource := db.SavedResource{
				CheckError: nil,
			}
			Expect(resource.FailingToCheck()).To(BeFalse())
		})
	})
})