# Sequel test guide - All controllers tests are to check that all the resources we expect to be created are present in the kubernetes cluster after reconcilation. **For `sequel`, `controller_test.go` is used to set up test environment/framework, and you will write actual tests on `user_controller_test.go`** - You will set up the according test variables for your own test case and then set up your sequel - Let's use example `TestCreateBuiltInUser` from `user_controller_test.go` - First, set up the test function: ``` func TestCreateBuiltInUser(t *testing.T) { } ``` - Set up your test user: ``` t.Skip("TODO(pa250194_ncrvoyix): fix errors") namespace := uuid.New().UUID usr := mockDatabaseUser("sequelbuiltinuser", namespace, backendv1.BuiltInUserType) ``` - Set up your sequel user name `BuiltIn User`, and add tests to verify its reconciliation status: ``` sequelUser := f2.NewFeature("BuiltIn User"). Test("BuiltIn User reconciles", func(ctx f2.Context, t *testing.T) f2.Context { k := ktest.FromContextT(ctx, t) assert.NilError(t, k.Client.Create(ctx, usr)) k.WaitOn(t, k.Check(usr, kmp.IsReady())) return ctx }). Test("Finalizer is added", func(ctx f2.Context, t *testing.T) f2.Context { if controllerutil.ContainsFinalizer(usr, backendv1.SequelFinalizer) { t.Error("finalizer not added to database user", spew.Sprintln(usr)) } return ctx }). Test("CloudSQL User created", func(ctx f2.Context, t *testing.T) f2.Context { k := ktest.FromContextT(ctx, t) cloudSQLUsr := &sqlAPI.SQLUser{} assert.NilError(t, k.Client.Get(ctx, types.NamespacedName{ Name: usr.Name, Namespace: usr.Namespace, }, cloudSQLUsr)) assert.Equal(t, cloudSQLUsr.Name, usr.Name) assert.Equal(t, cloudSQLUsr.Namespace, usr.Namespace) assert.Equal(t, cloudSQLUsr.Spec.Type, backendv1.BuiltInUserType) testifyAssert.Empty(t, cloudSQLUsr) return ctx }).Feature() f.Test(t, sequelUser) ``` # If you have any further question, please reach out to the platform team via #ncr-edge-api or #ncr-edge-backend :)