MCPcopy
hub / github.com/pocketbase/pocketbase / TestNewWithConfigAndFlags

Function TestNewWithConfigAndFlags

pocketbase_test.go:84–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestNewWithConfigAndFlags(t *testing.T) {
85 // copy os.Args
86 originalArgs := make([]string, len(os.Args))
87 copy(originalArgs, os.Args)
88 defer func() {
89 // restore os.Args
90 os.Args = originalArgs
91 }()
92
93 // change os.Args
94 os.Args = os.Args[:1]
95 os.Args = append(
96 os.Args,
97 "--dir=test_dir_flag",
98 "--encryptionEnv=test_encryption_env_flag",
99 "--debug=false",
100 )
101
102 app := NewWithConfig(Config{
103 DefaultDataDir: "test_dir",
104 DefaultEncryptionEnv: "test_encryption_env",
105 HideStartBanner: true,
106 })
107
108 if app == nil {
109 t.Fatal("Expected initialized PocketBase instance, got nil")
110 }
111
112 if app.RootCmd == nil {
113 t.Fatal("Expected RootCmd to be initialized, got nil")
114 }
115
116 if app.App == nil {
117 t.Fatal("Expected App to be initialized, got nil")
118 }
119
120 if app.hideStartBanner != true {
121 t.Fatal("Expected app.hideStartBanner to be true, got false")
122 }
123
124 if app.DataDir() != "test_dir_flag" {
125 t.Fatalf("Expected app.DataDir() %q, got %q", "test_dir_flag", app.DataDir())
126 }
127
128 if app.EncryptionEnv() != "test_encryption_env_flag" {
129 t.Fatalf("Expected app.EncryptionEnv() %q, got %q", "test_encryption_env_flag", app.EncryptionEnv())
130 }
131}
132
133func TestSkipBootstrap(t *testing.T) {
134 // copy os.Args

Callers

nothing calls this directly

Calls 4

copyFunction · 0.85
NewWithConfigFunction · 0.85
DataDirMethod · 0.65
EncryptionEnvMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…