Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pkg/server/remote_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
context "context"
"fmt"
"os"
"strings"

"github.com/linuxsuren/api-testing/pkg/render"
Expand All @@ -25,6 +26,22 @@ func NewRemoteServer() RunnerServer {
// Run start to run the test task
func (s *server) Run(ctx context.Context, task *TestTask) (reply *HelloReply, err error) {
var suite *testing.TestSuite
if task.Env == nil {
task.Env = map[string]string{}
}

// TODO may not safe in multiple threads
oldEnv := map[string]string{}
for key, val := range task.Env {
oldEnv[key] = os.Getenv(key)
os.Setenv(key, val)
}

defer func() {
for key, val := range oldEnv {
os.Setenv(key, val)
}
}()

switch task.Kind {
case "suite":
Expand Down Expand Up @@ -69,6 +86,7 @@ func (s *server) Run(ctx context.Context, task *TestTask) (reply *HelloReply, er
return
}

fmt.Println("prepare to run:", suite.Name)
dataContext := map[string]interface{}{}

var result string
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/remote_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ func TestRemoteServer(t *testing.T) {
Kind: "testcaseInSuite",
Data: simpleSuite,
CaseName: "fake",
Env: map[string]string{
"SERVER": "http://localhost:9090",
},
})
assert.NotNil(t, err)

Expand Down
Loading