Skip to content

Commit 8dc7464

Browse files
authored
tests: add version structure tests (#103)
* tests: add version structure tests Signed-off-by: Meenal Trivedi <[email protected]> * Replace empty body with nil * Fix
1 parent c26972f commit 8dc7464

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/apidoc_version_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package tests
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/tidwall/gjson"
8+
9+
"github.com/matrix-org/complement/internal/b"
10+
"github.com/matrix-org/complement/internal/match"
11+
"github.com/matrix-org/complement/internal/must"
12+
)
13+
14+
func TestVersionStructure(t *testing.T) {
15+
deployment := Deploy(t, "test_version", b.BlueprintAlice)
16+
defer deployment.Destroy(t)
17+
unauthedClient := deployment.Client(t, "hs1", "")
18+
// sytest: Version responds 200 OK with valid structure
19+
t.Run("Version responds 200 OK with valid structure", func(t *testing.T) {
20+
res := unauthedClient.MustDo(t, "GET", []string{"_matrix", "client", "versions"}, nil)
21+
22+
must.MatchResponse(t, res, match.HTTPResponse{
23+
JSON: []match.JSON{
24+
match.JSONKeyPresent("versions"),
25+
match.JSONArrayEach("versions", func(val gjson.Result) error {
26+
if val.Type != gjson.String {
27+
return fmt.Errorf("'versions' value is not a string: %s", val.Raw)
28+
}
29+
return nil
30+
}),
31+
},
32+
})
33+
})
34+
}

0 commit comments

Comments
 (0)