(t *testing.T)
| 932 | } |
| 933 | |
| 934 | func TestDefaultConfigBehavior(t *testing.T) { |
| 935 | t.Setenv("SQLITE_DATABASE", "\":memory:\"") |
| 936 | testCases := []struct { |
| 937 | desc string |
| 938 | args []string |
| 939 | expectRun bool |
| 940 | errString string |
| 941 | }{ |
| 942 | { |
| 943 | desc: "no flags (defaults to tools.yaml)", |
| 944 | args: []string{}, |
| 945 | expectRun: false, |
| 946 | errString: "tools.yaml", // Expect error because tools.yaml doesn't exist in test env |
| 947 | }, |
| 948 | { |
| 949 | desc: "prebuilt only (skips tools.yaml)", |
| 950 | args: []string{"--prebuilt", "sqlite"}, |
| 951 | expectRun: true, |
| 952 | }, |
| 953 | } |
| 954 | |
| 955 | for _, tc := range testCases { |
| 956 | t.Run(tc.desc, func(t *testing.T) { |
| 957 | ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) |
| 958 | defer cancel() |
| 959 | _, _, output, err := invokeCommandWithContext(ctx, tc.args) |
| 960 | |
| 961 | if tc.expectRun { |
| 962 | if err != nil && err != context.DeadlineExceeded && err != context.Canceled { |
| 963 | t.Fatalf("expected server start, got error: %v", err) |
| 964 | } |
| 965 | // Verify it actually started |
| 966 | if !strings.Contains(output, "Server ready to serve!") { |
| 967 | t.Errorf("server did not start successfully (no ready message found). Output:\n%s", output) |
| 968 | } |
| 969 | } else { |
| 970 | if err == nil { |
| 971 | t.Fatalf("expected error reading default file, got nil") |
| 972 | } |
| 973 | if !strings.Contains(err.Error(), tc.errString) { |
| 974 | t.Errorf("expected error message to contain %q, but got %q", tc.errString, err.Error()) |
| 975 | } |
| 976 | } |
| 977 | }) |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | func TestSubcommandWiring(t *testing.T) { |
| 982 | buf := new(bytes.Buffer) |
nothing calls this directly
no test coverage detected