github.com/ixpectus/declarate@v0.0.0-20240422152255-708027d7c068/tests/run_test.go (about)

     1  package tests
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/fatih/color"
     7  	"github.com/ixpectus/declarate/commands/db"
     8  	"github.com/ixpectus/declarate/commands/echo"
     9  	"github.com/ixpectus/declarate/commands/request"
    10  	"github.com/ixpectus/declarate/commands/vars"
    11  	"github.com/ixpectus/declarate/compare"
    12  	"github.com/ixpectus/declarate/contract"
    13  	"github.com/ixpectus/declarate/eval"
    14  	"github.com/ixpectus/declarate/kv"
    15  	"github.com/ixpectus/declarate/output"
    16  	"github.com/ixpectus/declarate/run"
    17  	"github.com/ixpectus/declarate/variables"
    18  )
    19  
    20  var (
    21  	evaluator  = eval.NewEval(nil)
    22  	vv         = variables.New(evaluator, kv.New("persistent", false), true)
    23  	cmp        = compare.New(contract.CompareParams{}, vv)
    24  	connLoader = db.NewPGLoader("postgres://postgres@127.0.0.1:5440/?sslmode=disable")
    25  	runner     = run.New(run.RunnerConfig{
    26  		Variables: vv,
    27  		Output:    &output.Output{},
    28  		Builders: []contract.CommandBuilder{
    29  			&echo.Unmarshaller{},
    30  			&vars.Unmarshaller{},
    31  			request.NewUnmarshaller("http://localhost:8181/", cmp),
    32  			db.NewUnmarshaller(connLoader, cmp),
    33  		},
    34  	})
    35  )
    36  
    37  func TestReq(t *testing.T) {
    38  	color.NoColor = false
    39  	runner.Run("./yaml/config_req.yaml", nil)
    40  	vv.Reset()
    41  }
    42  
    43  func TestDb(t *testing.T) {
    44  	color.NoColor = false
    45  	runner.Run("./yaml/db.yaml", nil)
    46  	vv.Reset()
    47  }
    48  
    49  func TestShell(t *testing.T) {
    50  	color.NoColor = false
    51  	runner.Run("./yaml/config_shell.yaml", nil)
    52  	vv.Reset()
    53  }