2021-02-10 03:36:07 +01:00
|
|
|
# Local Integration Tests
|
|
|
|
|
2021-02-12 03:04:53 +01:00
|
|
|
To run the tests.
|
2021-02-10 03:36:07 +01:00
|
|
|
|
|
|
|
```bash
|
|
|
|
sudo -E go test . -v
|
2021-02-12 03:04:53 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Adding a test
|
|
|
|
|
|
|
|
To add a test please try to have both `Happy` and `Sad` tests defined for all new SDK methods.
|
|
|
|
|
|
|
|
Example test:
|
|
|
|
|
|
|
|
#####mymethod_test.go
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
|
|
|
// TestHappyMethod will test my new method
|
|
|
|
func TestHappyMethod(t *testing.T) {
|
|
|
|
params := "my good input"
|
|
|
|
_, err := Client.V1().Method(params)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("expected success running method: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestSadMethod will false positive test my new method
|
|
|
|
func TestHappyMethod(t *testing.T) {
|
|
|
|
params := "my bad input"
|
|
|
|
_, err := Client.V1().Method(params)
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("expected failure running method: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-10 03:36:07 +01:00
|
|
|
```
|