Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/tests/components/database/db_test.go
2500 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package database
6
7
import (
8
"context"
9
"testing"
10
"time"
11
12
"sigs.k8s.io/e2e-framework/pkg/envconf"
13
"sigs.k8s.io/e2e-framework/pkg/features"
14
15
"github.com/gitpod-io/gitpod/test/pkg/integration"
16
)
17
18
func TestBuiltinUserExists(t *testing.T) {
19
f := features.New("database").
20
WithLabel("component", "database").
21
Assess("it should exists a builtin user workspace", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
22
ctx, cancel := context.WithTimeout(testCtx, 5*time.Minute)
23
defer cancel()
24
25
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
26
t.Cleanup(func() {
27
api.Done(t)
28
})
29
30
db, err := api.DB()
31
if err != nil {
32
t.Fatal(err)
33
}
34
35
rows, err := db.Query(`SELECT count(1) AS count FROM d_b_user WHERE id ="builtin-user-workspace-probe-0000000"`)
36
if err != nil {
37
t.Fatal(err)
38
}
39
defer rows.Close()
40
41
if !rows.Next() {
42
t.Fatal("no rows selected - should not happen")
43
}
44
45
var count int
46
err = rows.Scan(&count)
47
if err != nil {
48
t.Fatal(err)
49
}
50
51
if count != 1 {
52
t.Fatalf("expected a single builtin-user-workspace-probe-0000000, but found %d", count)
53
}
54
55
return testCtx
56
}).
57
Feature()
58
59
testEnv.Test(t, f)
60
}
61
62