Skip to content

Commit

Permalink
TMS-28784: support filters from the testit-cli package.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel.butuzov committed Dec 13, 2024
1 parent bfddc20 commit dd3aba9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ testit \
--testrun-id $(cat tmp/output.txt)
```

### Run with filter
To create filter by autotests you can use the Test IT CLI (use adapterMode 1 for run with filter):

```
$ export TMS_TOKEN=<YOUR_TOKEN>
$ testit autotests_filter
--url https://tms.testit.software \
--configuration-id 5236eb3f-7c05-46f9-a609-dc0278896464 \
--testrun-id 6d4ac4b7-dd67-4805-b879-18da0b89d4a8 \
--framework golang \
--output tmp/filter.txt
$ export TMS_TEST_RUN_ID=6d4ac4b7-dd67-4805-b879-18da0b89d4a8
$ export TMS_ADAPTER_MODE=1
$ export TMS_CONFIG_FILE=<ABSOLUTE_PATH_TO_CONFIG_FILE>
$ go test -run "$(cat tmp/filter.txt)"
```

### Metadata of autotest

Use metadata to specify information about autotest.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/ilyakaznacheev/cleanenv v1.5.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/testit-tms/api-client-golang v1.1.2 // indirect
github.com/testit-tms/api-client-golang v1.2.0 // indirect
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect
)

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/testit-tms/adapters-go/pkg/tms v0.0.0-20240131084840-12d96a19d482 h1:AptD3DRwK/w7MvS8s7Jo8SbuJ84I5o+o0XpaWpVkA5k=
github.com/testit-tms/adapters-go/pkg/tms v0.0.0-20240131084840-12d96a19d482/go.mod h1:IG8f12rZo58WCNcwdPmehiZrSQ70dTsuo4kLQ1zQt3w=
github.com/testit-tms/api-client-golang v1.1.2 h1:hvGYLmERYNedcyRXe/+MV7i4OmdHCYThTCKcuYGFM8g=
github.com/testit-tms/api-client-golang v1.1.2/go.mod h1:ei6jselOToVrifT9Bq3zDIFWKTBB/IWwITf4lJ3oUbs=
github.com/testit-tms/api-client-golang v1.2.0 h1:OcVWxc22RtU7r6sd99lOA77dqFdSl18eaCtosgT9y6s=
github.com/testit-tms/api-client-golang v1.2.0/go.mod h1:ei6jselOToVrifT9Bq3zDIFWKTBB/IWwITf4lJ3oUbs=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY=
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
4 changes: 2 additions & 2 deletions pkg/tms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *tmsClient) writeTest(test testResult) (string, error) {
return "", fmt.Errorf("%s: failed to create new autotest: %w", op, err)
}

autotestID = *na.Id
autotestID = *&na.Id
} else {
ur := testToUpdateAutotestModel(test, resp[0])
logger.Debug("update existing autotest", "request", ur)
Expand All @@ -100,7 +100,7 @@ func (c *tmsClient) writeTest(test testResult) (string, error) {
return "", fmt.Errorf("%s: failed to update existing autotest: %w", op, err)
}

autotestID = *resp[0].Id
autotestID = *&resp[0].Id
}

if len(test.workItemIds) != 0 {
Expand Down
7 changes: 5 additions & 2 deletions pkg/tms/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func testToAutotestModel(test testResult, projectId string) tmsclient.CreateAuto
req.SetSetup(stepToAutoTestStepModel(test.setups))
}

req.SetExternalKey(test.externalKey)

return *req
}

Expand Down Expand Up @@ -143,8 +145,9 @@ func testToUpdateAutotestModel(test testResult, autotest tmsclient.AutoTestModel
req.SetTeardown(stepToAutoTestStepModel(test.teardowns))
}

req.SetExternalKey(test.externalKey)
req.SetIsFlaky(*autotest.IsFlaky.Get())
req.SetId(*autotest.Id)
req.SetId(*&autotest.Id)

return *req
}
Expand Down Expand Up @@ -349,7 +352,7 @@ func testToUpdateResultModel(model *tmsclient.TestResultModel, test testResult)
req.SetAttachments(attachs)
}

req.SetOutcome(test.status)
req.SetOutcome(tmsclient.TestResultOutcome(test.status))

return *req, nil
}
2 changes: 2 additions & 0 deletions pkg/tms/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ func newTestResult(m TestMetadata, t *testing.T) *testResult {
testResult.externalId = hex.EncodeToString(hash[:])
}

testResult.externalKey = t.Name()

return testResult
}
1 change: 1 addition & 0 deletions pkg/tms/testresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type testResult struct {
startedOn time.Time
completedOn time.Time
duration int64
externalKey string
}

func (tr *testResult) addStatus(v string) {
Expand Down

0 comments on commit dd3aba9

Please sign in to comment.