Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
status: add test for getConsolidatedLatest()
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowlzz committed Sep 10, 2017
1 parent 4621913 commit bdc7710
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions cmd/dep/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,60 @@ func TestBasicStatusGetConsolidatedVersion(t *testing.T) {
})
}
}

func TestBasicStatusGetConsolidatedLatest(t *testing.T) {
testCases := []struct {
name string
basicStatus BasicStatus
revSize int
wantLatest string
}{
{
name: "empty BasicStatus",
basicStatus: BasicStatus{},
revSize: shortRev,
wantLatest: "",
},
{
name: "nil latest",
basicStatus: BasicStatus{
Latest: nil,
},
revSize: shortRev,
wantLatest: "",
},
{
name: "with error",
basicStatus: BasicStatus{
hasError: true,
},
revSize: shortRev,
wantLatest: "unknown",
},
{
name: "short latest",
basicStatus: BasicStatus{
Latest: gps.Revision("adummylonglongrevision"),
},
revSize: shortRev,
wantLatest: "adummyl",
},
{
name: "long latest",
basicStatus: BasicStatus{
Latest: gps.Revision("adummylonglongrevision"),
},
revSize: longRev,
wantLatest: "adummylonglongrevision",
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
gotRev := tc.basicStatus.getConsolidatedLatest(tc.revSize)
if gotRev != tc.wantLatest {
t.Errorf("unexpected consolidated latest: \n\t(GOT) %v \n\t(WNT) %v", gotRev, tc.wantLatest)
}
})
}
}

0 comments on commit bdc7710

Please sign in to comment.