Path: blob/main/test/tests/components/database/db_test.go
2500 views
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package database56import (7"context"8"testing"9"time"1011"sigs.k8s.io/e2e-framework/pkg/envconf"12"sigs.k8s.io/e2e-framework/pkg/features"1314"github.com/gitpod-io/gitpod/test/pkg/integration"15)1617func TestBuiltinUserExists(t *testing.T) {18f := features.New("database").19WithLabel("component", "database").20Assess("it should exists a builtin user workspace", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {21ctx, cancel := context.WithTimeout(testCtx, 5*time.Minute)22defer cancel()2324api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())25t.Cleanup(func() {26api.Done(t)27})2829db, err := api.DB()30if err != nil {31t.Fatal(err)32}3334rows, err := db.Query(`SELECT count(1) AS count FROM d_b_user WHERE id ="builtin-user-workspace-probe-0000000"`)35if err != nil {36t.Fatal(err)37}38defer rows.Close()3940if !rows.Next() {41t.Fatal("no rows selected - should not happen")42}4344var count int45err = rows.Scan(&count)46if err != nil {47t.Fatal(err)48}4950if count != 1 {51t.Fatalf("expected a single builtin-user-workspace-probe-0000000, but found %d", count)52}5354return testCtx55}).56Feature()5758testEnv.Test(t, f)59}606162