mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
sync the rest of the source models
refactor music download/storage to avoid re-download during reset add palylist to test server setup
This commit is contained in:
@@ -76,4 +76,215 @@ void main() {
|
||||
isNotNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('syncAlbums', () async {
|
||||
await db
|
||||
.into(db.albums)
|
||||
.insert(
|
||||
AlbumsCompanion.insert(
|
||||
sourceId: sourceId,
|
||||
id: 'shouldBeDeleted',
|
||||
name: 'shouldBeDeleted',
|
||||
created: DateTime.now(),
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.albums)
|
||||
.insert(
|
||||
AlbumsCompanion.insert(
|
||||
sourceId: sourceIdOther,
|
||||
id: 'shouldBeKept',
|
||||
name: 'shouldBeKept',
|
||||
created: DateTime.now(),
|
||||
),
|
||||
);
|
||||
|
||||
await sync.syncAlbums();
|
||||
|
||||
expect(
|
||||
await db.managers.albums
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(3),
|
||||
);
|
||||
expect(
|
||||
await db.managers.albums
|
||||
.filter((f) => f.id.equals('shouldBeDeleted'))
|
||||
.getSingleOrNull(),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
await db.managers.albums
|
||||
.filter((f) => f.id.equals('shouldBeKept'))
|
||||
.getSingleOrNull(),
|
||||
isNotNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('syncSongs', () async {
|
||||
await db
|
||||
.into(db.songs)
|
||||
.insert(
|
||||
SongsCompanion.insert(
|
||||
sourceId: sourceId,
|
||||
id: 'shouldBeDeleted',
|
||||
title: 'shouldBeDeleted',
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.songs)
|
||||
.insert(
|
||||
SongsCompanion.insert(
|
||||
sourceId: sourceIdOther,
|
||||
id: 'shouldBeKept',
|
||||
title: 'shouldBeKept',
|
||||
),
|
||||
);
|
||||
|
||||
await sync.syncSongs();
|
||||
|
||||
expect(
|
||||
await db.managers.songs
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(20),
|
||||
);
|
||||
expect(
|
||||
await db.managers.songs
|
||||
.filter((f) => f.id.equals('shouldBeDeleted'))
|
||||
.getSingleOrNull(),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
await db.managers.songs
|
||||
.filter((f) => f.id.equals('shouldBeKept'))
|
||||
.getSingleOrNull(),
|
||||
isNotNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('syncPlaylists', () async {
|
||||
await db
|
||||
.into(db.playlists)
|
||||
.insert(
|
||||
PlaylistsCompanion.insert(
|
||||
sourceId: sourceId,
|
||||
id: 'shouldBeDeleted',
|
||||
name: 'shouldBeDeleted',
|
||||
created: DateTime.now(),
|
||||
changed: DateTime.now(),
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.playlists)
|
||||
.insert(
|
||||
PlaylistsCompanion.insert(
|
||||
sourceId: sourceIdOther,
|
||||
id: 'shouldBeKept',
|
||||
name: 'shouldBeKept',
|
||||
created: DateTime.now(),
|
||||
changed: DateTime.now(),
|
||||
),
|
||||
);
|
||||
|
||||
await sync.syncPlaylists();
|
||||
|
||||
expect(
|
||||
await db.managers.playlists
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(1),
|
||||
);
|
||||
expect(
|
||||
await db.managers.playlists
|
||||
.filter((f) => f.id.equals('shouldBeDeleted'))
|
||||
.getSingleOrNull(),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
await db.managers.playlists
|
||||
.filter((f) => f.id.equals('shouldBeKept'))
|
||||
.getSingleOrNull(),
|
||||
isNotNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('syncPlaylistSongs', () async {
|
||||
await db
|
||||
.into(db.playlistSongs)
|
||||
.insert(
|
||||
PlaylistSongsCompanion.insert(
|
||||
sourceId: sourceId,
|
||||
playlistId: 'shouldBeDeleted',
|
||||
songId: 'shouldBeDeleted',
|
||||
position: 1,
|
||||
),
|
||||
);
|
||||
await db
|
||||
.into(db.playlistSongs)
|
||||
.insert(
|
||||
PlaylistSongsCompanion.insert(
|
||||
sourceId: sourceIdOther,
|
||||
playlistId: 'shouldBeKept',
|
||||
songId: 'shouldBeKept',
|
||||
position: 1,
|
||||
),
|
||||
);
|
||||
|
||||
await sync.syncPlaylistSongs();
|
||||
|
||||
expect(
|
||||
await db.managers.playlistSongs
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(7),
|
||||
);
|
||||
expect(
|
||||
await db.managers.playlistSongs
|
||||
.filter((f) => f.playlistId.equals('shouldBeDeleted'))
|
||||
.getSingleOrNull(),
|
||||
isNull,
|
||||
);
|
||||
expect(
|
||||
await db.managers.playlistSongs
|
||||
.filter((f) => f.playlistId.equals('shouldBeKept'))
|
||||
.getSingleOrNull(),
|
||||
isNotNull,
|
||||
);
|
||||
});
|
||||
|
||||
test('syncPlaylistSongs', () async {
|
||||
await sync.sync();
|
||||
|
||||
expect(
|
||||
await db.managers.artists
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(2),
|
||||
);
|
||||
expect(
|
||||
await db.managers.albums
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(3),
|
||||
);
|
||||
expect(
|
||||
await db.managers.songs
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(20),
|
||||
);
|
||||
expect(
|
||||
await db.managers.playlists
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(1),
|
||||
);
|
||||
expect(
|
||||
await db.managers.playlistSongs
|
||||
.filter((f) => f.sourceId.equals(sourceId))
|
||||
.count(),
|
||||
equals(7),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ void main() {
|
||||
test('allPlaylists', () async {
|
||||
final items = await source.allPlaylists().toList();
|
||||
|
||||
expect(items.length, equals(0));
|
||||
expect(items.length, equals(1));
|
||||
});
|
||||
|
||||
test('allPlaylistSongs', () async {
|
||||
final items = await source.allPlaylistSongs().toList();
|
||||
|
||||
expect(items.length, equals(0));
|
||||
expect(items.length, equals(7));
|
||||
});
|
||||
|
||||
test('album-artist relation', () async {
|
||||
|
||||
Reference in New Issue
Block a user