github.com/billybanfield/evergreen@v0.0.0-20170525200750-eeee692790f7/apiv3/servicecontext/context.go (about) 1 package servicecontext 2 3 import ( 4 "github.com/evergreen-ci/evergreen/model" 5 ) 6 7 // DBContextConnector is a struct that implements the Context related 8 // functions of the ServiceConnector interface through interactions 9 // with the backing database. 10 type DBContextConnector struct{} 11 12 // LoadContext fetches the context through a call to the service layer. 13 func (dc *DBContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error) { 14 return model.LoadContext(taskId, buildId, versionId, patchId, projectId) 15 } 16 17 // MockContextConnector is a struct that mocks the context methods 18 // by storing context to be fetched by its method. 19 type MockContextConnector struct { 20 CachedContext model.Context 21 CachedErr error 22 } 23 24 // FetchContext returns the context cached within the MockContextConnector. 25 func (mc *MockContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error) { 26 return mc.CachedContext, mc.CachedErr 27 }