...
1
2
3
4
5
6
7
8
9
10
11
12
13 package client
14
15 import (
16 "context"
17 "regexp"
18
19 kivik "github.com/go-kivik/kivik/v4"
20 "github.com/go-kivik/kivik/v4/kiviktest/kt"
21 )
22
23 func init() {
24 kt.Register("Version", version)
25 }
26
27 func version(ctx *kt.Context) {
28 ctx.RunAdmin(func(ctx *kt.Context) {
29 testServerInfo(ctx, ctx.Admin)
30 })
31 ctx.RunNoAuth(func(ctx *kt.Context) {
32 testServerInfo(ctx, ctx.NoAuth)
33 })
34 }
35
36 func testServerInfo(ctx *kt.Context, client *kivik.Client) {
37 ctx.Parallel()
38 info, err := client.Version(context.Background())
39 if !ctx.IsExpectedSuccess(err) {
40 return
41 }
42 version := regexp.MustCompile(ctx.MustString("version"))
43 vendor := regexp.MustCompile(ctx.MustString("vendor"))
44 if !version.MatchString(info.Version) {
45 ctx.Errorf("Version '%s' does not match /%s/", info.Version, version)
46 }
47 if !vendor.MatchString(info.Vendor) {
48 ctx.Errorf("Vendor '%s' does not match /%s/", info.Vendor, vendor)
49 }
50 }
51
View as plain text