feat: empty test for argparser; assertion helpers
This commit is contained in:
23
internal/argparser/argparser_test.go
Normal file
23
internal/argparser/argparser_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package argparser
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"gitea.kevinnlsamuel.com/kevinnls/qc/internal/testing/assert"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
t.Run("no args", func(t *testing.T) {
|
||||
error,ctype,cscope,shouldCommit,shouldStage,cmessage := Parse([]string{})
|
||||
assert.Equal(t, error, nil)
|
||||
assert.Equal(t, ctype, "")
|
||||
assert.Equal(t, cscope, "")
|
||||
wantedMessage := []string{}
|
||||
for i := 0; i < len(wantedMessage); i++ {
|
||||
if wantedMessage[i] != cmessage[i] {
|
||||
t.Errorf("messages do not match")
|
||||
}
|
||||
}
|
||||
assert.Equal(t, shouldCommit, false)
|
||||
assert.Equal(t, shouldStage, false)
|
||||
})
|
||||
}
|
||||
15
internal/testing/assert/assert.go
Normal file
15
internal/testing/assert/assert.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package assert
|
||||
|
||||
import "testing"
|
||||
|
||||
func Equal[T comparable](t *testing.T, got, want T) {
|
||||
if (got != want) {
|
||||
t.Errorf("not equal %v and %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func NotEqual[T comparable](t *testing.T, got, want T) {
|
||||
if (got == want) {
|
||||
t.Errorf("unexpected equal %v and %v", got, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user