summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-26 15:31:00 +0530
committerAndinus <andinus@nand.sh>2020-03-26 15:31:00 +0530
commitafd4130b382c333e746adff49ce5d2c554d3045d (patch)
tree7a06bbf55af38a69b6aae11b991a8e116b16812b
parent945ea27d5ffb0c8d85a6bfa535a6cd21a1227ae3 (diff)
downloadcetus-afd4130b382c333e746adff49ce5d2c554d3045d.tar.gz
Add test for RandDate func
-rw-r--r--apod/randomdate_test.go18
-rw-r--r--build/ci/drone.yml3
2 files changed, 21 insertions, 0 deletions
diff --git a/apod/randomdate_test.go b/apod/randomdate_test.go
new file mode 100644
index 0000000..8ac82bc
--- /dev/null
+++ b/apod/randomdate_test.go
@@ -0,0 +1,18 @@
+package apod
+
+import (
+	"regexp"
+	"testing"
+)
+
+// TestRandDate tests the RandDate func. We're not actually testing
+// much, there are many cases and we really can't test for all, we'll
+// have to run this test a lot of times for that. Even after that it
+// doesn't guarantee anything because our test itself is flawed.
+func TestRandDate(t *testing.T) {
+	date := RandDate()
+	re := regexp.MustCompile("((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])")
+	if !re.MatchString(date) {
+		t.Errorf("Date format is incorrect, got %s, want YYYY-MM-DD.", date)
+	}
+}
diff --git a/build/ci/drone.yml b/build/ci/drone.yml
index 2e1b9b0..3ab75ba 100644
--- a/build/ci/drone.yml
+++ b/build/ci/drone.yml
@@ -9,6 +9,7 @@ steps:
     GOARCH: amd64
     GOOS: openbsd
   commands:
+  - go test -v ./...
   - go build ./cmd/cetus
 
 - name: build-linux
@@ -17,6 +18,7 @@ steps:
     GOARCH: amd64
     GOOS: linux
   commands:
+  - go test -v ./...
   - go build ./cmd/cetus
 
 - name: build-darwin
@@ -25,4 +27,5 @@ steps:
     GOARCH: amd64
     GOOS: darwin
   commands:
+  - go test -v ./...
   - go build ./cmd/cetus