Increase test coverage.

This commit is contained in:
2022-10-17 15:30:21 +01:00
parent 3e885b5e7c
commit be885367df
+50 -1
View File
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -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)
}
})
}
}