diff --git a/database/service.go b/database/service.go index edec864c..de239ff6 100644 --- a/database/service.go +++ b/database/service.go @@ -35,18 +35,21 @@ var ( // Service is the database representation of a service in a build. type Service struct { - ID sql.NullInt64 `sql:"id"` - BuildID sql.NullInt64 `sql:"build_id"` - RepoID sql.NullInt64 `sql:"repo_id"` - Number sql.NullInt32 `sql:"number"` - Name sql.NullString `sql:"name"` - Image sql.NullString `sql:"image"` - Status sql.NullString `sql:"status"` - Error sql.NullString `sql:"error"` - ExitCode sql.NullInt32 `sql:"exit_code"` - Created sql.NullInt64 `sql:"created"` - Started sql.NullInt64 `sql:"started"` - Finished sql.NullInt64 `sql:"finished"` + ID sql.NullInt64 `sql:"id"` + BuildID sql.NullInt64 `sql:"build_id"` + RepoID sql.NullInt64 `sql:"repo_id"` + Number sql.NullInt32 `sql:"number"` + Name sql.NullString `sql:"name"` + Image sql.NullString `sql:"image"` + Status sql.NullString `sql:"status"` + Error sql.NullString `sql:"error"` + ExitCode sql.NullInt32 `sql:"exit_code"` + Created sql.NullInt64 `sql:"created"` + Started sql.NullInt64 `sql:"started"` + Finished sql.NullInt64 `sql:"finished"` + Host sql.NullString `sql:"host"` + Runtime sql.NullString `sql:"runtime"` + Distribution sql.NullString `sql:"distribution"` } // Nullify ensures the valid flag for @@ -120,6 +123,21 @@ func (s *Service) Nullify() *Service { s.Finished.Valid = false } + // check if the Host field should be false + if len(s.Host.String) == 0 { + s.Host.Valid = false + } + + // check if the Runtime field should be false + if len(s.Runtime.String) == 0 { + s.Runtime.Valid = false + } + + // check if the Distribution field should be false + if len(s.Distribution.String) == 0 { + s.Distribution.Valid = false + } + return s } @@ -140,6 +158,9 @@ func (s *Service) ToLibrary() *library.Service { service.SetCreated(s.Created.Int64) service.SetStarted(s.Started.Int64) service.SetFinished(s.Finished.Int64) + service.SetHost(s.Host.String) + service.SetRuntime(s.Runtime.String) + service.SetDistribution(s.Distribution.String) return service } @@ -179,18 +200,21 @@ func (s *Service) Validate() error { // to a database Service type. func ServiceFromLibrary(s *library.Service) *Service { service := &Service{ - ID: sql.NullInt64{Int64: s.GetID(), Valid: true}, - BuildID: sql.NullInt64{Int64: s.GetBuildID(), Valid: true}, - RepoID: sql.NullInt64{Int64: s.GetRepoID(), Valid: true}, - Number: sql.NullInt32{Int32: int32(s.GetNumber()), Valid: true}, - Name: sql.NullString{String: s.GetName(), Valid: true}, - Image: sql.NullString{String: s.GetImage(), Valid: true}, - Status: sql.NullString{String: s.GetStatus(), Valid: true}, - Error: sql.NullString{String: s.GetError(), Valid: true}, - ExitCode: sql.NullInt32{Int32: int32(s.GetExitCode()), Valid: true}, - Created: sql.NullInt64{Int64: s.GetCreated(), Valid: true}, - Started: sql.NullInt64{Int64: s.GetStarted(), Valid: true}, - Finished: sql.NullInt64{Int64: s.GetFinished(), Valid: true}, + ID: sql.NullInt64{Int64: s.GetID(), Valid: true}, + BuildID: sql.NullInt64{Int64: s.GetBuildID(), Valid: true}, + RepoID: sql.NullInt64{Int64: s.GetRepoID(), Valid: true}, + Number: sql.NullInt32{Int32: int32(s.GetNumber()), Valid: true}, + Name: sql.NullString{String: s.GetName(), Valid: true}, + Image: sql.NullString{String: s.GetImage(), Valid: true}, + Status: sql.NullString{String: s.GetStatus(), Valid: true}, + Error: sql.NullString{String: s.GetError(), Valid: true}, + ExitCode: sql.NullInt32{Int32: int32(s.GetExitCode()), Valid: true}, + Created: sql.NullInt64{Int64: s.GetCreated(), Valid: true}, + Started: sql.NullInt64{Int64: s.GetStarted(), Valid: true}, + Finished: sql.NullInt64{Int64: s.GetFinished(), Valid: true}, + Host: sql.NullString{String: s.GetHost(), Valid: true}, + Runtime: sql.NullString{String: s.GetRuntime(), Valid: true}, + Distribution: sql.NullString{String: s.GetDistribution(), Valid: true}, } return service.Nullify() diff --git a/database/service_test.go b/database/service_test.go index c72c8f62..6fb1b91e 100644 --- a/database/service_test.go +++ b/database/service_test.go @@ -15,32 +15,38 @@ import ( func TestDatabase_Service_Nullify(t *testing.T) { // setup types s := &Service{ - ID: sql.NullInt64{Int64: 0, Valid: true}, - BuildID: sql.NullInt64{Int64: 0, Valid: true}, - RepoID: sql.NullInt64{Int64: 0, Valid: true}, - Number: sql.NullInt32{Int32: 0, Valid: true}, - Name: sql.NullString{String: "", Valid: true}, - Image: sql.NullString{String: "", Valid: true}, - Status: sql.NullString{String: "", Valid: true}, - Error: sql.NullString{String: "", Valid: true}, - ExitCode: sql.NullInt32{Int32: 0, Valid: true}, - Created: sql.NullInt64{Int64: 0, Valid: true}, - Started: sql.NullInt64{Int64: 0, Valid: true}, - Finished: sql.NullInt64{Int64: 0, Valid: true}, + ID: sql.NullInt64{Int64: 0, Valid: true}, + BuildID: sql.NullInt64{Int64: 0, Valid: true}, + RepoID: sql.NullInt64{Int64: 0, Valid: true}, + Number: sql.NullInt32{Int32: 0, Valid: true}, + Name: sql.NullString{String: "", Valid: true}, + Image: sql.NullString{String: "", Valid: true}, + Status: sql.NullString{String: "", Valid: true}, + Error: sql.NullString{String: "", Valid: true}, + ExitCode: sql.NullInt32{Int32: 0, Valid: true}, + Created: sql.NullInt64{Int64: 0, Valid: true}, + Started: sql.NullInt64{Int64: 0, Valid: true}, + Finished: sql.NullInt64{Int64: 0, Valid: true}, + Host: sql.NullString{String: "", Valid: true}, + Runtime: sql.NullString{String: "", Valid: true}, + Distribution: sql.NullString{String: "", Valid: true}, } want := &Service{ - ID: sql.NullInt64{Int64: 0, Valid: false}, - BuildID: sql.NullInt64{Int64: 0, Valid: false}, - RepoID: sql.NullInt64{Int64: 0, Valid: false}, - Number: sql.NullInt32{Int32: 0, Valid: false}, - Name: sql.NullString{String: "", Valid: false}, - Image: sql.NullString{String: "", Valid: false}, - Status: sql.NullString{String: "", Valid: false}, - Error: sql.NullString{String: "", Valid: false}, - ExitCode: sql.NullInt32{Int32: 0, Valid: false}, - Created: sql.NullInt64{Int64: 0, Valid: false}, - Started: sql.NullInt64{Int64: 0, Valid: false}, - Finished: sql.NullInt64{Int64: 0, Valid: false}, + ID: sql.NullInt64{Int64: 0, Valid: false}, + BuildID: sql.NullInt64{Int64: 0, Valid: false}, + RepoID: sql.NullInt64{Int64: 0, Valid: false}, + Number: sql.NullInt32{Int32: 0, Valid: false}, + Name: sql.NullString{String: "", Valid: false}, + Image: sql.NullString{String: "", Valid: false}, + Status: sql.NullString{String: "", Valid: false}, + Error: sql.NullString{String: "", Valid: false}, + ExitCode: sql.NullInt32{Int32: 0, Valid: false}, + Created: sql.NullInt64{Int64: 0, Valid: false}, + Started: sql.NullInt64{Int64: 0, Valid: false}, + Finished: sql.NullInt64{Int64: 0, Valid: false}, + Host: sql.NullString{String: "", Valid: false}, + Runtime: sql.NullString{String: "", Valid: false}, + Distribution: sql.NullString{String: "", Valid: false}, } // run test @@ -70,32 +76,38 @@ func TestDatabase_Service_ToLibrary(t *testing.T) { num64 := int64(num) str := "foo" want := &library.Service{ - ID: &num64, - BuildID: &num64, - RepoID: &num64, - Number: &num, - Name: &str, - Image: &str, - Status: &str, - Error: &str, - ExitCode: &num, - Created: &num64, - Started: &num64, - Finished: &num64, + ID: &num64, + BuildID: &num64, + RepoID: &num64, + Number: &num, + Name: &str, + Image: &str, + Status: &str, + Error: &str, + ExitCode: &num, + Created: &num64, + Started: &num64, + Finished: &num64, + Host: &str, + Runtime: &str, + Distribution: &str, } s := &Service{ - ID: sql.NullInt64{Int64: num64, Valid: true}, - BuildID: sql.NullInt64{Int64: num64, Valid: true}, - RepoID: sql.NullInt64{Int64: num64, Valid: true}, - Number: sqlNum, - Name: sql.NullString{String: str, Valid: true}, - Image: sql.NullString{String: str, Valid: true}, - Status: sql.NullString{String: str, Valid: true}, - Error: sql.NullString{String: str, Valid: true}, - ExitCode: sqlNum, - Created: sql.NullInt64{Int64: num64, Valid: true}, - Started: sql.NullInt64{Int64: num64, Valid: true}, - Finished: sql.NullInt64{Int64: num64, Valid: true}, + ID: sql.NullInt64{Int64: num64, Valid: true}, + BuildID: sql.NullInt64{Int64: num64, Valid: true}, + RepoID: sql.NullInt64{Int64: num64, Valid: true}, + Number: sqlNum, + Name: sql.NullString{String: str, Valid: true}, + Image: sql.NullString{String: str, Valid: true}, + Status: sql.NullString{String: str, Valid: true}, + Error: sql.NullString{String: str, Valid: true}, + ExitCode: sqlNum, + Created: sql.NullInt64{Int64: num64, Valid: true}, + Started: sql.NullInt64{Int64: num64, Valid: true}, + Finished: sql.NullInt64{Int64: num64, Valid: true}, + Host: sql.NullString{String: str, Valid: true}, + Runtime: sql.NullString{String: str, Valid: true}, + Distribution: sql.NullString{String: str, Valid: true}, } // run test @@ -217,32 +229,38 @@ func TestDatabase_ServiceFromLibrary(t *testing.T) { num64 := int64(num) str := "foo" want := &Service{ - ID: sql.NullInt64{Int64: num64, Valid: true}, - BuildID: sql.NullInt64{Int64: num64, Valid: true}, - RepoID: sql.NullInt64{Int64: num64, Valid: true}, - Number: sqlNum, - Name: sql.NullString{String: str, Valid: true}, - Image: sql.NullString{String: str, Valid: true}, - Status: sql.NullString{String: str, Valid: true}, - Error: sql.NullString{String: str, Valid: true}, - ExitCode: sqlNum, - Created: sql.NullInt64{Int64: num64, Valid: true}, - Started: sql.NullInt64{Int64: num64, Valid: true}, - Finished: sql.NullInt64{Int64: num64, Valid: true}, + ID: sql.NullInt64{Int64: num64, Valid: true}, + BuildID: sql.NullInt64{Int64: num64, Valid: true}, + RepoID: sql.NullInt64{Int64: num64, Valid: true}, + Number: sqlNum, + Name: sql.NullString{String: str, Valid: true}, + Image: sql.NullString{String: str, Valid: true}, + Status: sql.NullString{String: str, Valid: true}, + Error: sql.NullString{String: str, Valid: true}, + ExitCode: sqlNum, + Created: sql.NullInt64{Int64: num64, Valid: true}, + Started: sql.NullInt64{Int64: num64, Valid: true}, + Finished: sql.NullInt64{Int64: num64, Valid: true}, + Host: sql.NullString{String: str, Valid: true}, + Runtime: sql.NullString{String: str, Valid: true}, + Distribution: sql.NullString{String: str, Valid: true}, } s := &library.Service{ - ID: &num64, - BuildID: &num64, - RepoID: &num64, - Number: &num, - Name: &str, - Image: &str, - Status: &str, - Error: &str, - ExitCode: &num, - Created: &num64, - Started: &num64, - Finished: &num64, + ID: &num64, + BuildID: &num64, + RepoID: &num64, + Number: &num, + Name: &str, + Image: &str, + Status: &str, + Error: &str, + ExitCode: &num, + Created: &num64, + Started: &num64, + Finished: &num64, + Host: &str, + Runtime: &str, + Distribution: &str, } // run test diff --git a/library/service.go b/library/service.go index 00d52dd9..c67b0d7e 100644 --- a/library/service.go +++ b/library/service.go @@ -8,18 +8,21 @@ import "fmt" // Service is the library representation of a service in a build. type Service struct { - ID *int64 `json:"id,omitempty"` - BuildID *int64 `json:"build_id,omitempty"` - RepoID *int64 `json:"repo_id,omitempty"` - Number *int `json:"number,omitempty"` - Name *string `json:"name,omitempty"` - Image *string `json:"image,omitempty"` - Status *string `json:"status,omitempty"` - Error *string `json:"error,omitempty"` - ExitCode *int `json:"exit_code,omitempty"` - Created *int64 `json:"created,omitempty"` - Started *int64 `json:"started,omitempty"` - Finished *int64 `json:"finished,omitempty"` + ID *int64 `json:"id,omitempty"` + BuildID *int64 `json:"build_id,omitempty"` + RepoID *int64 `json:"repo_id,omitempty"` + Number *int `json:"number,omitempty"` + Name *string `json:"name,omitempty"` + Image *string `json:"image,omitempty"` + Status *string `json:"status,omitempty"` + Error *string `json:"error,omitempty"` + ExitCode *int `json:"exit_code,omitempty"` + Created *int64 `json:"created,omitempty"` + Started *int64 `json:"started,omitempty"` + Finished *int64 `json:"finished,omitempty"` + Host *string `json:"host,omitempty"` + Runtime *string `json:"runtime,omitempty"` + Distribution *string `json:"distribution,omitempty"` } // GetID returns the ID field. @@ -178,6 +181,45 @@ func (s *Service) GetFinished() int64 { return *s.Finished } +// GetHost returns the Host field. +// +// When the provided Service type is nil, or the field within +// the type is nil, it returns the zero value for the field. +func (s *Service) GetHost() string { + // return zero value if Service type or Host field is nil + if s == nil || s.Host == nil { + return "" + } + + return *s.Host +} + +// GetRuntime returns the Runtime field. +// +// When the provided Service type is nil, or the field within +// the type is nil, it returns the zero value for the field. +func (s *Service) GetRuntime() string { + // return zero value if Service type or Runtime field is nil + if s == nil || s.Runtime == nil { + return "" + } + + return *s.Runtime +} + +// GetDistribution returns the Runtime field. +// +// When the provided Service type is nil, or the field within +// the type is nil, it returns the zero value for the field. +func (s *Service) GetDistribution() string { + // return zero value if Service type or Distribution field is nil + if s == nil || s.Distribution == nil { + return "" + } + + return *s.Distribution +} + // SetID sets the ID field. // // When the provided Service type is nil, it @@ -334,6 +376,45 @@ func (s *Service) SetFinished(v int64) { s.Finished = &v } +// SetHost sets the Host field. +// +// When the provided Service type is nil, it +// will set nothing and immediately return. +func (s *Service) SetHost(v string) { + // return if Service type is nil + if s == nil { + return + } + + s.Host = &v +} + +// SetRuntime sets the Runtime field. +// +// When the provided Service type is nil, it +// will set nothing and immediately return. +func (s *Service) SetRuntime(v string) { + // return if Service type is nil + if s == nil { + return + } + + s.Runtime = &v +} + +// SetDistribution sets the Runtime field. +// +// When the provided Service type is nil, it +// will set nothing and immediately return. +func (s *Service) SetDistribution(v string) { + // return if Service type is nil + if s == nil { + return + } + + s.Distribution = &v +} + // String implements the Stringer interface for the Service type. func (s *Service) String() string { return fmt.Sprintf("%+v", *s) diff --git a/library/service_test.go b/library/service_test.go index f8ec3775..ad2f5b39 100644 --- a/library/service_test.go +++ b/library/service_test.go @@ -16,18 +16,21 @@ func TestService_Getters(t *testing.T) { num64 := int64(num) str := "foo" s := &Service{ - ID: &num64, - BuildID: &num64, - RepoID: &num64, - Number: &num, - Name: &str, - Image: &str, - Status: &str, - Error: &str, - ExitCode: &num, - Created: &num64, - Started: &num64, - Finished: &num64, + ID: &num64, + BuildID: &num64, + RepoID: &num64, + Number: &num, + Name: &str, + Image: &str, + Status: &str, + Error: &str, + ExitCode: &num, + Created: &num64, + Started: &num64, + Finished: &num64, + Host: &str, + Runtime: &str, + Distribution: &str, } wantID := num64 wantBuildID := num64 @@ -41,6 +44,9 @@ func TestService_Getters(t *testing.T) { wantCreated := num64 wantStarted := num64 wantFinished := num64 + wantHost := str + wantRuntime := str + wantDistribution := str // run test gotID := s.GetID() @@ -55,43 +61,69 @@ func TestService_Getters(t *testing.T) { gotCreated := s.GetCreated() gotStarted := s.GetStarted() gotFinished := s.GetFinished() + gotHost := s.GetHost() + gotRuntime := s.GetRuntime() + gotDistribution := s.GetDistribution() if gotID != wantID { t.Errorf("GetID is %v, want %v", gotID, wantID) } + if gotBuildID != wantBuildID { t.Errorf("GetBuildID is %v, want %v", gotBuildID, wantBuildID) } + if gotRepoID != wantRepoID { t.Errorf("GetRepoID is %v, want %v", gotRepoID, wantRepoID) } + if gotNumber != wantNumber { t.Errorf("GetNumber is %v, want %v", gotNumber, wantNumber) } + if gotName != wantName { t.Errorf("GetName is %v, want %v", gotName, wantName) } + if gotImage != wantImage { t.Errorf("GetImage is %v, want %v", gotImage, wantImage) } + if gotStatus != wantStatus { t.Errorf("GetStatus is %v, want %v", gotStatus, wantStatus) } + if gotError != wantError { t.Errorf("GetError is %v, want %v", gotError, wantError) } + if gotExitCode != wantExitCode { t.Errorf("GetExitCode is %v, want %v", gotExitCode, wantExitCode) } + if gotCreated != wantCreated { t.Errorf("GetCreated is %v, want %v", gotCreated, wantCreated) } + if gotStarted != wantStarted { t.Errorf("GetStarted is %v, want %v", gotStarted, wantStarted) } + if gotFinished != wantFinished { t.Errorf("GetFinished is %v, want %v", gotFinished, wantFinished) } + + if gotHost != wantHost { + t.Errorf("GetHost is %v, want %v", gotHost, wantHost) + } + + if gotRuntime != wantRuntime { + t.Errorf("GetRuntime is %v, want %v", gotRuntime, wantRuntime) + } + + if gotDistribution != wantDistribution { + t.Errorf("GetDistribution is %v, want %v", gotDistribution, wantDistribution) + } } func TestService_Getters_Empty(t *testing.T) { @@ -111,43 +143,69 @@ func TestService_Getters_Empty(t *testing.T) { gotCreated := s.GetCreated() gotStarted := s.GetStarted() gotFinished := s.GetFinished() + gotHost := s.GetHost() + gotRuntime := s.GetRuntime() + gotDistribution := s.GetDistribution() if gotID != 0 { t.Errorf("GetID is %v, want 0", gotID) } + if gotBuildID != 0 { t.Errorf("GetBuildID is %v, want 0", gotBuildID) } + if gotRepoID != 0 { t.Errorf("GetRepoID is %v, want 0", gotRepoID) } + if gotNumber != 0 { t.Errorf("GetNumber is %v, want 0", gotNumber) } + if gotName != "" { t.Errorf("GetName is %v, want \"\"", gotName) } + if gotImage != "" { t.Errorf("GetImage is %v, want \"\"", gotImage) } + if gotStatus != "" { t.Errorf("GetStatus is %v, want \"\"", gotStatus) } + if gotError != "" { t.Errorf("GetError is %v, want \"\"", gotError) } + if gotExitCode != 0 { t.Errorf("GetExitCode is %v, want 0", gotExitCode) } + if gotCreated != 0 { t.Errorf("GetCreated is %v, want 0", gotCreated) } + if gotStarted != 0 { t.Errorf("GetStarted is %v, want 0", gotStarted) } + if gotFinished != 0 { t.Errorf("GetFinished is %v, want 0", gotFinished) } + + if gotHost != "" { + t.Errorf("GetHost is %v, want \"\"", gotHost) + } + + if gotRuntime != "" { + t.Errorf("GetRuntime is %v, want \"\"", gotRuntime) + } + + if gotDistribution != "" { + t.Errorf("GetDistribution is %v, want \"\"", gotDistribution) + } } func TestLibrary_Service_Setters(t *testing.T) { @@ -169,6 +227,9 @@ func TestLibrary_Service_Setters(t *testing.T) { wantCreated := num64 wantStarted := num64 wantFinished := num64 + wantHost := str + wantRuntime := str + wantDistribution := str // run test s.SetID(wantID) @@ -183,43 +244,69 @@ func TestLibrary_Service_Setters(t *testing.T) { s.SetCreated(wantCreated) s.SetStarted(wantStarted) s.SetFinished(wantFinished) + s.SetHost(wantHost) + s.SetRuntime(wantRuntime) + s.SetDistribution(wantDistribution) if s.GetID() != wantID { t.Errorf("SetID is %v, want %v", s.GetID(), wantID) } + if s.GetBuildID() != wantBuildID { t.Errorf("SetBuildID is %v, want %v", s.GetBuildID(), wantBuildID) } + if s.GetRepoID() != wantRepoID { t.Errorf("SetRepoID is %v, want %v", s.GetRepoID(), wantRepoID) } + if s.GetNumber() != wantNumber { t.Errorf("SetNumber is %v, want %v", s.GetNumber(), wantNumber) } + if s.GetName() != wantName { t.Errorf("SetName is %v, want %v", s.GetName(), wantName) } + if s.GetImage() != wantImage { t.Errorf("SetImage is %v, want %v", s.GetImage(), wantImage) } + if s.GetStatus() != wantStatus { t.Errorf("SetStatus is %v, want %v", s.GetStatus(), wantStatus) } + if s.GetError() != wantError { t.Errorf("SetError is %v, want %v", s.GetError(), wantError) } + if s.GetExitCode() != wantExitCode { t.Errorf("SetExitCode is %v, want %v", s.GetExitCode(), wantExitCode) } + if s.GetCreated() != wantCreated { t.Errorf("SetCreated is %v, want %v", s.GetCreated(), wantCreated) } + if s.GetStarted() != wantStarted { t.Errorf("SetStarted is %v, want %v", s.GetStarted(), wantStarted) } + if s.GetFinished() != wantFinished { t.Errorf("SetFinished is %v, want %v", s.GetFinished(), wantFinished) } + + if s.GetHost() != wantHost { + t.Errorf("SetHost is %v, want %v", s.GetHost(), wantHost) + } + + if s.GetRuntime() != wantRuntime { + t.Errorf("SetRuntime is %v, want %v", s.GetRuntime(), wantRuntime) + } + + if s.GetDistribution() != wantDistribution { + t.Errorf("SetDistribution is %v, want %v", s.GetDistribution(), wantDistribution) + } } func TestLibrary_Service_Setters_Empty(t *testing.T) { @@ -239,43 +326,69 @@ func TestLibrary_Service_Setters_Empty(t *testing.T) { s.SetCreated(0) s.SetStarted(0) s.SetFinished(0) + s.SetHost("") + s.SetRuntime("") + s.SetDistribution("") if s.GetID() != 0 { t.Errorf("SetID is %v, want 0", s.GetID()) } + if s.GetBuildID() != 0 { t.Errorf("SetBuildID is %v, want 0", s.GetBuildID()) } + if s.GetRepoID() != 0 { t.Errorf("SetRepoID is %v, want 0", s.GetRepoID()) } + if s.GetNumber() != 0 { t.Errorf("SetNumber is %v, want 0", s.GetNumber()) } + if s.GetName() != "" { t.Errorf("SetName is %v, want \"\"", s.GetName()) } + if s.GetImage() != "" { t.Errorf("SetImage is %v, want \"\"", s.GetImage()) } + if s.GetStatus() != "" { t.Errorf("SetStatus is %v, want \"\"", s.GetStatus()) } + if s.GetError() != "" { t.Errorf("SetError is %v, want \"\"", s.GetError()) } + if s.GetExitCode() != 0 { t.Errorf("SetExitCode is %v, want 0", s.GetExitCode()) } + if s.GetCreated() != 0 { t.Errorf("SetCreated is %v, want 0", s.GetCreated()) } + if s.GetStarted() != 0 { t.Errorf("SetStarted is %v, want 0", s.GetStarted()) } + if s.GetFinished() != 0 { t.Errorf("SetFinished is %v, want 0", s.GetFinished()) } + + if s.GetHost() != "" { + t.Errorf("SetHost is %v, want \"\"", s.GetHost()) + } + + if s.GetRuntime() != "" { + t.Errorf("SetRuntime is %v, want \"\"", s.GetRuntime()) + } + + if s.GetDistribution() != "" { + t.Errorf("SetDistribution is %v, want \"\"", s.GetDistribution()) + } } func TestService_String(t *testing.T) { @@ -284,19 +397,23 @@ func TestService_String(t *testing.T) { num64 := int64(num) str := "foo" s := &Service{ - ID: &num64, - BuildID: &num64, - RepoID: &num64, - Number: &num, - Name: &str, - Image: &str, - Status: &str, - Error: &str, - ExitCode: &num, - Created: &num64, - Started: &num64, - Finished: &num64, + ID: &num64, + BuildID: &num64, + RepoID: &num64, + Number: &num, + Name: &str, + Image: &str, + Status: &str, + Error: &str, + ExitCode: &num, + Created: &num64, + Started: &num64, + Finished: &num64, + Host: &str, + Runtime: &str, + Distribution: &str, } + want := fmt.Sprintf("%+v", *s) // run test