Compare commits

...

2 Commits

Author SHA1 Message Date
9f6e503379 feat: empty test for argparser; assertion helpers 2024-01-21 10:55:21 +05:30
2e7f59a069 make target tests everything 2024-01-21 10:20:58 +05:30
3 changed files with 39 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ prefix = podman run --interactive --tty --rm \
run:
$(prefix) go run $(GO_MODULE) $(ARGS)
test:
$(prefix) go test $(GO_MODULE) $(ARGS)
$(prefix) go test ./... $(ARGS)
build:
$(prefix) go build -v $(GO_MODULE) $(ARGS)
sh:

View 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)
})
}

View 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)
}
}