Test that testtool won't check coverage of imported package e.g. net/http.
This commit is contained in:
parent
9848183cc1
commit
a9ca8a5c7c
10 changed files with 42 additions and 2 deletions
|
@ -6,10 +6,11 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"gitlab.com/slon/shad-go/coverme"
|
||||
)
|
||||
|
||||
// min coverage: 60%
|
||||
// min coverage: 70%
|
||||
|
||||
func TestSum(t *testing.T) {
|
||||
require.Equal(t, int64(2), coverme.Sum(1, 1))
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
package coverme
|
||||
|
||||
import "net/http"
|
||||
|
||||
func Sum(a, b int64) int64 {
|
||||
if a == 0 {
|
||||
return b
|
||||
} else if a == http.StatusOK {
|
||||
return http.StatusCreated + b - 1
|
||||
}
|
||||
return a + b
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ import (
|
|||
func TestSum(t *testing.T) {
|
||||
require.Equal(t, int64(2), Sum(1, 1))
|
||||
require.Equal(t, int64(1), Sum(0, 1))
|
||||
require.Equal(t, int64(202), Sum(200, 2))
|
||||
}
|
||||
|
|
5
tools/testtool/testdata/submissions/correct/coverme/private/coverme/subpkg/g.go
vendored
Normal file
5
tools/testtool/testdata/submissions/correct/coverme/private/coverme/subpkg/g.go
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
package subpkg
|
||||
|
||||
func AddTwo(n int) int {
|
||||
return AddOne(n + 1)
|
||||
}
|
11
tools/testtool/testdata/submissions/correct/coverme/student/coverme/additional_test.go
vendored
Normal file
11
tools/testtool/testdata/submissions/correct/coverme/student/coverme/additional_test.go
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
package coverme
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSum2(t *testing.T) {
|
||||
require.Equal(t, int64(202), Sum(200, 2))
|
||||
}
|
|
@ -6,10 +6,11 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"gitlab.com/slon/shad-go/coverme"
|
||||
)
|
||||
|
||||
// min coverage: 60%
|
||||
// min coverage: 70%
|
||||
|
||||
func TestSum(t *testing.T) {
|
||||
require.Equal(t, int64(2), coverme.Sum(1, 1))
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
package coverme
|
||||
|
||||
import "net/http"
|
||||
|
||||
func Sum(a, b int64) int64 {
|
||||
if a == 0 {
|
||||
return b
|
||||
} else if a == http.StatusOK {
|
||||
return http.StatusCreated + b - 1
|
||||
}
|
||||
return a + b
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ func TestAddOne_2(t *testing.T) {
|
|||
require.Equal(t, 2, AddOne(1))
|
||||
require.Equal(t, 30, AddOne(29))
|
||||
}
|
||||
|
||||
func TestAddTwo(t *testing.T) {
|
||||
require.Equal(t, 4, AddTwo(2))
|
||||
}
|
||||
|
|
5
tools/testtool/testdata/submissions/correct/coverme/student/coverme/subpkg/g.go
vendored
Normal file
5
tools/testtool/testdata/submissions/correct/coverme/student/coverme/subpkg/g.go
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
package subpkg
|
||||
|
||||
func AddTwo(n int) int {
|
||||
return AddOne(n + 1)
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
Loading…
Reference in a new issue