Compare commits
2 Commits
cc2bdcc28f
...
9f6e503379
| Author | SHA1 | Date | |
|---|---|---|---|
|
9f6e503379
|
|||
|
2e7f59a069
|
2
Makefile
2
Makefile
@@ -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:
|
||||
|
||||
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