-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_bootstrap_test.go
More file actions
44 lines (36 loc) · 1.05 KB
/
Copy pathconfig_bootstrap_test.go
File metadata and controls
44 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package contexting
import (
"os"
"path/filepath"
"testing"
)
func TestWriteStarterConfig(t *testing.T) {
tmpDir := t.TempDir()
path := filepath.Join(tmpDir, "context.toml")
if err := writeStarterConfig(path, false); err != nil {
t.Fatalf("writeStarterConfig failed: %v", err)
}
bytes, err := os.ReadFile(path)
if err != nil {
t.Fatalf("read written config: %v", err)
}
if len(bytes) == 0 {
t.Fatalf("expected non-empty starter config")
}
if err := writeStarterConfig(path, false); err == nil {
t.Fatalf("expected error when writing existing config without force")
}
if err := writeStarterConfig(path, true); err != nil {
t.Fatalf("expected overwrite with force, got: %v", err)
}
}
func TestEnsureStarterConfigPromptAutoCreate(t *testing.T) {
tmpDir := t.TempDir()
path := filepath.Join(tmpDir, "context.toml")
if _, err := ensureStarterConfigPrompt(path, true); err != nil {
t.Fatalf("ensureStarterConfigPrompt auto-create failed: %v", err)
}
if _, err := os.Stat(path); err != nil {
t.Fatalf("expected config to exist: %v", err)
}
}