Skip to content

Commit

Permalink
enhance: adding branch to Schedule data type and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Claire.Nicholas authored and Claire.Nicholas committed Aug 21, 2023
1 parent 2606daf commit 0fc2ad0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions database/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestDatabase_ScheduleFromLibrary(t *testing.T) {
s.SetUpdatedAt(time.Now().Add(time.Hour * 1).UTC().Unix())
s.SetUpdatedBy("user2")
s.SetScheduledAt(time.Now().Add(time.Hour * 2).UTC().Unix())
s.SetBranch("main")

want := testSchedule()

Expand Down Expand Up @@ -59,6 +60,7 @@ func TestDatabase_Schedule_Nullify(t *testing.T) {
UpdatedAt: sql.NullInt64{Int64: 0, Valid: false},
UpdatedBy: sql.NullString{String: "", Valid: false},
ScheduledAt: sql.NullInt64{Int64: 0, Valid: false},
Branch: sql.NullString{String: "", Valid: false},
},
},
{
Expand Down Expand Up @@ -90,6 +92,7 @@ func TestDatabase_Schedule_ToLibrary(t *testing.T) {
want.SetUpdatedAt(time.Now().Add(time.Hour * 1).UTC().Unix())
want.SetUpdatedBy("user2")
want.SetScheduledAt(time.Now().Add(time.Hour * 2).UTC().Unix())
want.SetBranch("main")

got := testSchedule().ToLibrary()
if !reflect.DeepEqual(got, want) {
Expand Down Expand Up @@ -176,5 +179,6 @@ func testSchedule() *Schedule {
UpdatedAt: sql.NullInt64{Int64: time.Now().Add(time.Hour * 1).UTC().Unix(), Valid: true},
UpdatedBy: sql.NullString{String: "user2", Valid: true},
ScheduledAt: sql.NullInt64{Int64: time.Now().Add(time.Hour * 2).UTC().Unix(), Valid: true},
Branch: sql.NullString{String: "main", Valid: true},
}
}
10 changes: 10 additions & 0 deletions library/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func TestLibrary_Schedule_Getters(t *testing.T) {
if test.schedule.GetScheduledAt() != test.want.GetScheduledAt() {
t.Errorf("GetScheduledAt is %v, want %v", test.schedule.GetScheduledAt(), test.want.GetScheduledAt())
}
if test.schedule.GetBranch() != test.want.GetBranch() {
t.Errorf("GetBranch is %v, want %v", test.schedule.GetBranch(), test.want.GetBranch())
}
})
}
}
Expand Down Expand Up @@ -136,6 +139,10 @@ func TestLibrary_Schedule_Setters(t *testing.T) {
if test.schedule.GetScheduledAt() != test.want.GetScheduledAt() {
t.Errorf("SetScheduledAt is %v, want %v", test.schedule.GetScheduledAt(), test.want.GetScheduledAt())
}
test.schedule.SetBranch(test.want.GetBranch())
if test.schedule.GetBranch() != test.want.GetBranch() {
t.Errorf("SetBranch is %v, want %v", test.schedule.GetBranch(), test.want.GetBranch())
}
})
}
}
Expand All @@ -154,6 +161,7 @@ func TestLibrary_Schedule_String(t *testing.T) {
ScheduledAt: %d,
UpdatedAt: %d,
UpdatedBy: %s,
Branch: %s,
}`,
s.GetActive(),
s.GetCreatedAt(),
Expand All @@ -165,6 +173,7 @@ func TestLibrary_Schedule_String(t *testing.T) {
s.GetScheduledAt(),
s.GetUpdatedAt(),
s.GetUpdatedBy(),
s.GetBranch(),
)

got := s.String()
Expand All @@ -186,6 +195,7 @@ func testSchedule() *Schedule {
s.SetUpdatedAt(time.Now().Add(time.Hour * 1).UTC().Unix())
s.SetUpdatedBy("user2")
s.SetScheduledAt(time.Now().Add(time.Hour * 2).UTC().Unix())
s.SetBranch("main")

return s
}

0 comments on commit 0fc2ad0

Please sign in to comment.