Skip to content

Commit

Permalink
[tests] Fix init logic
Browse files Browse the repository at this point in the history
Signed-off-by: weiyang <weiyang.ones@gmail.com>
  • Loading branch information
wy-z committed Nov 26, 2018
1 parent 639a65e commit 224236c
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions tspec/tspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tspec_test
import (
"bytes"
"encoding/json"
"fmt"
"go/ast"
"testing"

Expand All @@ -12,8 +11,6 @@ import (
"github.com/wy-z/tspec/tspec"
)

var samplesPackage *ast.Package

func TestTSpec(t *testing.T) {
suite.Run(t, new(TSpecTestSuite))
}
Expand All @@ -25,8 +22,10 @@ type TSpecTestSuite struct {
}

func (s *TSpecTestSuite) SetupTest() {
var err error
s.parser = tspec.NewParser()
s.pkg = samplesPackage
s.pkg, err = s.parser.Import("github.com/wy-z/tspec/samples")
s.Require().NoError(err)
}

func (s *TSpecTestSuite) testParse(typeStr, assert string) {
Expand Down Expand Up @@ -62,12 +61,3 @@ func (s *TSpecTestSuite) TestParseInvalidMap() {
require.Error(err)
require.Nil(schema)
}

func init() {
pkg, err := tspec.NewParser().Import("github.com/wy-z/tspec/samples")
if err != nil {
msg := fmt.Sprintf("failed to import 'github.com/wy-z/tspec/samples': %s", err)
panic(msg)
}
samplesPackage = pkg
}

0 comments on commit 224236c

Please sign in to comment.