(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func TestDBFilePath(t *testing.T) { |
| 129 | tmpDir, _ := filepath.EvalSymlinks(t.TempDir()) |
| 130 | cases := []struct { |
| 131 | dsn string |
| 132 | expected string |
| 133 | }{ |
| 134 | {":memory:", ""}, |
| 135 | {"file:rill?mode=memory&cache=shared", ""}, |
| 136 | {"file::memory:?cache=shared", ""}, |
| 137 | {filepath.Join(tmpDir, "data.sqlite"), filepath.Join(tmpDir, "data.sqlite")}, |
| 138 | {"file:" + filepath.Join(tmpDir, "data.sqlite"), filepath.Join(tmpDir, "data.sqlite")}, |
| 139 | } |
| 140 | for idx, tc := range cases { |
| 141 | t.Run(fmt.Sprintf("case-%d", idx), func(t *testing.T) { |
| 142 | cfg := map[string]any{"dsn": tc.dsn} |
| 143 | h, err := driver{}.Open("", "", cfg, storage.MustNew(t.TempDir(), nil), activity.NewNoopClient(), zap.NewNop()) |
| 144 | require.NoError(t, err) |
| 145 | defer h.Close() |
| 146 | |
| 147 | dbPath, err := h.(*connection).dbFilePath(t.Context()) |
| 148 | require.NoError(t, err) |
| 149 | require.Equal(t, tc.expected, dbPath) |
| 150 | }) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func must[T any](v T, err error) T { |
| 155 | if err != nil { |
nothing calls this directly
no test coverage detected