(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestNew(t *testing.T) { |
| 12 | // copy os.Args |
| 13 | originalArgs := make([]string, len(os.Args)) |
| 14 | copy(originalArgs, os.Args) |
| 15 | defer func() { |
| 16 | // restore os.Args |
| 17 | os.Args = originalArgs |
| 18 | }() |
| 19 | |
| 20 | // change os.Args |
| 21 | os.Args = os.Args[:1] |
| 22 | os.Args = append( |
| 23 | os.Args, |
| 24 | "--dir=test_dir", |
| 25 | "--encryptionEnv=test_encryption_env", |
| 26 | "--debug=true", |
| 27 | ) |
| 28 | |
| 29 | app := New() |
| 30 | |
| 31 | if app == nil { |
| 32 | t.Fatal("Expected initialized PocketBase instance, got nil") |
| 33 | } |
| 34 | |
| 35 | if app.RootCmd == nil { |
| 36 | t.Fatal("Expected RootCmd to be initialized, got nil") |
| 37 | } |
| 38 | |
| 39 | if app.App == nil { |
| 40 | t.Fatal("Expected App to be initialized, got nil") |
| 41 | } |
| 42 | |
| 43 | if app.DataDir() != "test_dir" { |
| 44 | t.Fatalf("Expected app.DataDir() %q, got %q", "test_dir", app.DataDir()) |
| 45 | } |
| 46 | |
| 47 | if app.EncryptionEnv() != "test_encryption_env" { |
| 48 | t.Fatalf("Expected app.EncryptionEnv() test_encryption_env, got %q", app.EncryptionEnv()) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestNewWithConfig(t *testing.T) { |
| 53 | app := NewWithConfig(Config{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…