(t *testing.T)
| 1247 | } |
| 1248 | |
| 1249 | func TestAppStoreUsesAppScopedStorage(t *testing.T) { |
| 1250 | storage := newFakeAppStorage() |
| 1251 | store := NewAppStore("app_xxx", storage) |
| 1252 | if got := store.Path(); got != "apps:app_xxx/"+MetadataFilename { |
| 1253 | t.Fatalf("Path() = %q, want app-scoped path", got) |
| 1254 | } |
| 1255 | empty, err := store.Load() |
| 1256 | if err != nil { |
| 1257 | t.Fatalf("Load missing app storage returned error: %v", err) |
| 1258 | } |
| 1259 | if empty.Version != CurrentCredentialVersion { |
| 1260 | t.Fatalf("empty version = %d, want %d", empty.Version, CurrentCredentialVersion) |
| 1261 | } |
| 1262 | record := CredentialRecord{AppID: "app_xxx", GitHTTPURL: "https://example.com/git/u/app.git", Profile: "default", ProfileAppID: "cli_xxx", UserOpenID: "ou_xxx", Status: StatusConfirmed} |
| 1263 | if err := store.Upsert(record); err != nil { |
| 1264 | t.Fatalf("Upsert app storage returned error: %v", err) |
| 1265 | } |
| 1266 | if storage.values["app_xxx/"+MetadataFilename] == nil { |
| 1267 | t.Fatalf("app storage missing metadata key") |
| 1268 | } |
| 1269 | records, err := store.Records() |
| 1270 | if err != nil { |
| 1271 | t.Fatalf("Records app storage returned error: %v", err) |
| 1272 | } |
| 1273 | if len(records) != 1 || records[0].GitHTTPURL != record.GitHTTPURL { |
| 1274 | t.Fatalf("records = %#v, want stored record", records) |
| 1275 | } |
| 1276 | deleted, err := store.DeleteByURL(record.GitHTTPURL) |
| 1277 | if err != nil { |
| 1278 | t.Fatalf("DeleteByURL app storage returned error: %v", err) |
| 1279 | } |
| 1280 | if deleted == nil || deleted.GitHTTPURL != record.GitHTTPURL { |
| 1281 | t.Fatalf("deleted = %#v, want stored record", deleted) |
| 1282 | } |
| 1283 | if storage.values["app_xxx/"+MetadataFilename] != nil { |
| 1284 | t.Fatalf("app storage metadata still present after delete") |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | func TestNewStoreUsesConfigDir(t *testing.T) { |
| 1289 | configDir := t.TempDir() |
nothing calls this directly
no test coverage detected