mirror of
https://github.com/lukaszraczylo/semver-generator.git
synced 2026-06-13 01:11:00 +00:00
Increase test coverage.
This commit is contained in:
@@ -581,3 +581,52 @@ func (suite *Tests) Test_parseExistingSemver() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *Tests) TestSetup_ListExistingTags() {
|
||||||
|
type fields struct {
|
||||||
|
RepositoryName string
|
||||||
|
RepositoryLocalPath string
|
||||||
|
RepositoryHandler *git.Repository
|
||||||
|
LocalConfigFile string
|
||||||
|
Commits []CommitDetails
|
||||||
|
Semver SemVer
|
||||||
|
Wording Wording
|
||||||
|
Force Force
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
noTags bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "List tags from existing repository",
|
||||||
|
fields: fields{
|
||||||
|
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client",
|
||||||
|
},
|
||||||
|
noTags: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "List tags from non-existing repository",
|
||||||
|
fields: fields{
|
||||||
|
RepositoryName: "https://github.com/lukaszraczylo/simple-gql-client-dead",
|
||||||
|
},
|
||||||
|
noTags: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
suite.T().Run(tt.name, func(t *testing.T) {
|
||||||
|
s := &Setup{}
|
||||||
|
s.ReadConfig(tt.fields.LocalConfigFile)
|
||||||
|
s.RepositoryName = tt.fields.RepositoryName
|
||||||
|
s.Force = tt.fields.Force
|
||||||
|
s.Prepare()
|
||||||
|
s.ListExistingTags()
|
||||||
|
if tt.noTags {
|
||||||
|
assert.Equal(len(s.Tags), 0, "Unexpected number of tags in "+tt.name)
|
||||||
|
} else {
|
||||||
|
assert.GreaterOrEqual(len(s.Tags), 1, "Unexpected number of tags in "+tt.name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user