test: add smoke tests on some basic calls

pull/17/head
Dominique Merle 2 years ago
parent 84112768aa
commit e93b3d8fa3

@ -18,11 +18,20 @@ jobs:
with:
go-version: 1.17
- name: Install UPX
run: apt install upx
- name: Go Get Govvv
run: go get github.com/ahmetb/govvv
- name: Go Get
run: go get
- name: Integration Tests
run: go test -v
- name: Build Linux
run: go build -v -o mj
run: ./build.sh
- name: Test
- name: Test Build
run: ./mj example/example.csv --sort

@ -1,6 +1,7 @@
#!/bin/bash
# Install govvv first
# Install things first
#apt install upx
#go get github.com/ahmetb/govvv
go build \

@ -6,16 +6,19 @@ require (
github.com/mieuxvoter/majority-judgment-library-go v0.2.2
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect

@ -0,0 +1,98 @@
package main
import (
"os"
"testing"
)
//func Test(t *testing.T) {
// os.Args = []string{os.Args[0], "example/example6.csv", "--format", "gnuplot"}
// main()
//}
//func Test2(t *testing.T) {
// os.Args = []string{os.Args[0], "example/example6.csv", "--fo"}
// main()
//}
var testData = []struct {
name string
args []string
code int
stdout string
stderr string
}{
{
name: "Basic usage, example.csv",
args: []string{
"example/example.csv",
},
},
{
name: "Basic usage, example1.csv",
args: []string{
"example/example1.csv",
},
},
{
name: "Basic usage, example2.csv",
args: []string{
"example/example2.csv",
},
},
{
name: "Basic usage, example3.csv",
args: []string{
"example/example3.csv",
},
},
{
name: "Basic usage, example4.csv",
args: []string{
"example/example4.csv",
},
},
{
name: "Basic usage, example5.csv",
args: []string{
"example/example5.csv",
},
},
{
name: "Basic usage, example6.csv",
args: []string{
"example/example6.csv",
},
},
{
name: "--sort usage, example.csv",
args: []string{
"example/example.csv",
"--sort",
},
},
{
name: "--format gnuplot, example.csv",
args: []string{
"example/example.csv",
"--format",
"gnuplot",
},
},
}
func TestAll(t *testing.T) {
for _, tt := range testData {
t.Run(tt.name, func(t *testing.T) {
os.Args = []string{os.Args[0]}
os.Args = append(os.Args, tt.args...)
main()
// How to do?
// Check return code against tt.code
// Check stdout against tt.stdout
// Check stderr against tt.stderr
})
}
}
Loading…
Cancel
Save