Skip to content

Commit d575ab6

Browse files
committed
refactor(nextcloud_test): remove default timeout and retryCount
Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
1 parent 3560124 commit d575ab6

16 files changed

+2718
-2810
lines changed

packages/nextcloud/test/cookbook_test.dart

+150-156
Original file line numberDiff line numberDiff line change
@@ -5,201 +5,195 @@ import 'package:nextcloud_test/nextcloud_test.dart';
55
import 'package:test/test.dart';
66

77
void main() {
8-
presets(
9-
'cookbook',
10-
'cookbook',
11-
(tester) {
12-
group('CookbookVersionCheck', () {
13-
test('Is supported', () async {
14-
final response = await tester.client.cookbook.getVersionCheck();
15-
16-
expect(response.isSupported, isTrue);
17-
});
8+
presets('cookbook', 'cookbook', (tester) {
9+
group('CookbookVersionCheck', () {
10+
test('Is supported', () async {
11+
final response = await tester.client.cookbook.getVersionCheck();
12+
13+
expect(response.isSupported, isTrue);
1814
});
15+
});
1916

20-
group('categories', () {
21-
test('listCategories', () async {
22-
final response = await tester.client.cookbook.categories.listCategories();
17+
group('categories', () {
18+
test('listCategories', () async {
19+
final response = await tester.client.cookbook.categories.listCategories();
2320

24-
expect(response.body, hasLength(7));
25-
});
21+
expect(response.body, hasLength(7));
22+
});
23+
24+
test('recipesInCategory', () async {
25+
final response = await tester.client.cookbook.categories.recipesInCategory(category: 'Soup');
2626

27-
test('recipesInCategory', () async {
28-
final response = await tester.client.cookbook.categories.recipesInCategory(category: 'Soup');
27+
expect(response.body, hasLength(2));
28+
});
2929

30-
expect(response.body, hasLength(2));
30+
test('renameCategory', () async {
31+
final recipe = cookbook.RecipeBuilder()
32+
..name = 'My super cool recipe'
33+
..dateCreated = DateTime.utc(2023).toIso8601String()
34+
..recipeCategory = 'Test';
35+
final createResponse = await tester.client.cookbook.recipes.newRecipe($body: recipe.build());
36+
addTearDown(() async {
37+
closeFixture();
38+
await tester.client.cookbook.recipes.deleteRecipe(id: createResponse.body.toString());
3139
});
40+
expect(createResponse.body, isNotNull);
3241

33-
test('renameCategory', () async {
34-
final recipe = cookbook.RecipeBuilder()
35-
..name = 'My super cool recipe'
36-
..dateCreated = DateTime.utc(2023).toIso8601String()
37-
..recipeCategory = 'Test';
38-
final createResponse = await tester.client.cookbook.recipes.newRecipe($body: recipe.build());
39-
addTearDown(() async {
40-
closeFixture();
41-
await tester.client.cookbook.recipes.deleteRecipe(id: createResponse.body.toString());
42-
});
43-
expect(createResponse.body, isNotNull);
44-
45-
final request = cookbook.RenameCategoryRequestApplicationJsonBuilder()..name = 'Delicious Soup';
46-
47-
final response = await tester.client.cookbook.categories.renameCategory(
48-
category: 'Test',
49-
$body: request.build(),
50-
);
42+
final request = cookbook.RenameCategoryRequestApplicationJsonBuilder()..name = 'Delicious Soup';
5143

52-
expect(response.body, request.name);
53-
});
44+
final response = await tester.client.cookbook.categories.renameCategory(
45+
category: 'Test',
46+
$body: request.build(),
47+
);
48+
49+
expect(response.body, request.name);
50+
});
51+
});
52+
53+
group('misc', () {
54+
final expectedConfig = cookbook.ConfigBuilder()
55+
..folder = '/Recipes'
56+
..updateInterval = 5
57+
..printImage = true
58+
..visibleInfoBlocks.update(
59+
(b) => b
60+
..preparationTime = true
61+
..cookingTime = true
62+
..totalTime = true
63+
..nutritionInformation = true
64+
..tools = true,
65+
);
66+
67+
test('getConfig', () async {
68+
final response = await tester.client.cookbook.misc.getConfig();
69+
70+
expect(response.body, equalsBuilt(expectedConfig.build()));
5471
});
5572

56-
group('misc', () {
57-
final expectedConfig = cookbook.ConfigBuilder()
58-
..folder = '/Recipes'
59-
..updateInterval = 5
60-
..printImage = true
61-
..visibleInfoBlocks.update(
62-
(b) => b
63-
..preparationTime = true
64-
..cookingTime = true
65-
..totalTime = true
66-
..nutritionInformation = true
67-
..tools = true,
68-
);
73+
test('reindex', () async {
74+
final response = await tester.client.cookbook.misc.reindex();
6975

70-
test('getConfig', () async {
71-
final response = await tester.client.cookbook.misc.getConfig();
76+
expect(response.body, 'Search index rebuilt successfully');
77+
});
7278

73-
expect(response.body, equalsBuilt(expectedConfig.build()));
79+
test('setConfig', () async {
80+
addTearDown(() async {
81+
closeFixture();
82+
await tester.client.cookbook.misc.setConfig($body: expectedConfig.build());
7483
});
7584

76-
test('reindex', () async {
77-
final response = await tester.client.cookbook.misc.reindex();
85+
final config = cookbook.ConfigBuilder()..folder = '/';
86+
final response = await tester.client.cookbook.misc.setConfig($body: config.build());
7887

79-
expect(response.body, 'Search index rebuilt successfully');
80-
});
88+
expect(response.body, 'OK');
89+
});
8190

82-
test('setConfig', () async {
83-
addTearDown(() async {
84-
closeFixture();
85-
await tester.client.cookbook.misc.setConfig($body: expectedConfig.build());
86-
});
91+
test('version', () async {
92+
final response = await tester.client.cookbook.misc.version();
8793

88-
final config = cookbook.ConfigBuilder()..folder = '/';
89-
final response = await tester.client.cookbook.misc.setConfig($body: config.build());
94+
final cookbookVersion = response.body.cookbookVersion!;
95+
expect(cookbookVersion[0], JsonObject(tester.version.major));
96+
expect(cookbookVersion[1], JsonObject(tester.version.minor));
97+
});
98+
});
9099

91-
expect(response.body, 'OK');
100+
group('recipes', () {
101+
test('callImport', () async {
102+
final url = cookbook.UrlBuilder()..url = '${tester.targetURL}/static/recipe.html';
103+
final response = await tester.client.cookbook.recipes.$import($body: url.build());
104+
addTearDown(() async {
105+
closeFixture();
106+
await tester.client.cookbook.recipes.deleteRecipe(id: response.body.id!);
92107
});
93108

94-
test('version', () async {
95-
final response = await tester.client.cookbook.misc.version();
96-
97-
final cookbookVersion = response.body.cookbookVersion!;
98-
expect(cookbookVersion[0], JsonObject(tester.version.major));
99-
expect(cookbookVersion[1], JsonObject(tester.version.minor));
100-
});
109+
expect(response.body, isA<cookbook.Recipe>());
101110
});
102111

103-
group('recipes', () {
104-
test('callImport', () async {
105-
final url = cookbook.UrlBuilder()..url = '${tester.targetURL}/static/recipe.html';
106-
final response = await tester.client.cookbook.recipes.$import($body: url.build());
107-
addTearDown(() async {
108-
closeFixture();
109-
await tester.client.cookbook.recipes.deleteRecipe(id: response.body.id!);
110-
});
112+
test('getImage', () async {
113+
final recipes = await tester.client.cookbook.recipes.listRecipes();
114+
final recipeWithoutImage = recipes.body.firstWhere((stub) => stub.name == 'Recipe Without an image');
115+
final response = await tester.client.cookbook.recipes.getImage(
116+
id: recipeWithoutImage.id,
117+
);
111118

112-
expect(response.body, isA<cookbook.Recipe>());
113-
});
119+
expect(response.body, isNotNull);
114120

115-
test('getImage', () async {
116-
final recipes = await tester.client.cookbook.recipes.listRecipes();
117-
final recipeWithoutImage = recipes.body.firstWhere((stub) => stub.name == 'Recipe Without an image');
118-
final response = await tester.client.cookbook.recipes.getImage(
119-
id: recipeWithoutImage.id,
120-
);
121+
final recipeWithImage = recipes.body.firstWhere((stub) => stub.name == "Chef John's Gazpacho");
122+
final response2 = await tester.client.cookbook.recipes.getImage(
123+
id: recipeWithImage.id,
124+
size: cookbook.GetImageSize.full,
125+
);
121126

122-
expect(response.body, isNotNull);
123-
124-
final recipeWithImage = recipes.body.firstWhere((stub) => stub.name == "Chef John's Gazpacho");
125-
final response2 = await tester.client.cookbook.recipes.getImage(
126-
id: recipeWithImage.id,
127-
size: cookbook.GetImageSize.full,
128-
);
129-
130-
expect(response2.body, isNotNull);
131-
});
127+
expect(response2.body, isNotNull);
128+
});
132129

133-
test('listRecipes', () async {
134-
final response = await tester.client.cookbook.recipes.listRecipes();
130+
test('listRecipes', () async {
131+
final response = await tester.client.cookbook.recipes.listRecipes();
135132

136-
expect(response.body, hasLength(19));
137-
});
133+
expect(response.body, hasLength(19));
134+
});
138135

139-
test('newRecipe and deleteRecipe', () async {
140-
final recipe = cookbook.RecipeBuilder()
141-
..name = 'My super cool recipe'
142-
..dateCreated = DateTime.utc(2023).toIso8601String();
143-
final createResponse = await tester.client.cookbook.recipes.newRecipe($body: recipe.build());
144-
expect(createResponse.body, isNotNull);
136+
test('newRecipe and deleteRecipe', () async {
137+
final recipe = cookbook.RecipeBuilder()
138+
..name = 'My super cool recipe'
139+
..dateCreated = DateTime.utc(2023).toIso8601String();
140+
final createResponse = await tester.client.cookbook.recipes.newRecipe($body: recipe.build());
141+
expect(createResponse.body, isNotNull);
145142

146-
final deleteResponse = await tester.client.cookbook.recipes.deleteRecipe(id: createResponse.body.toString());
147-
expect(deleteResponse.body, equals('Recipe ${createResponse.body} deleted successfully'));
148-
});
143+
final deleteResponse = await tester.client.cookbook.recipes.deleteRecipe(id: createResponse.body.toString());
144+
expect(deleteResponse.body, equals('Recipe ${createResponse.body} deleted successfully'));
145+
});
149146

150-
test('recipeDetails', () async {
151-
final recipes = await tester.client.cookbook.recipes.listRecipes();
147+
test('recipeDetails', () async {
148+
final recipes = await tester.client.cookbook.recipes.listRecipes();
152149

153-
for (final recipe in recipes.body) {
154-
final response = await tester.client.cookbook.recipes.recipeDetails(
155-
id: recipe.id,
156-
);
150+
for (final recipe in recipes.body) {
151+
final response = await tester.client.cookbook.recipes.recipeDetails(
152+
id: recipe.id,
153+
);
157154

158-
expect(response.body, isNotNull);
159-
}
160-
});
155+
expect(response.body, isNotNull);
156+
}
157+
});
161158

162-
test('search', () async {
163-
final response = await tester.client.cookbook.recipes.search(query: 'Vegan');
159+
test('search', () async {
160+
final response = await tester.client.cookbook.recipes.search(query: 'Vegan');
164161

165-
expect(response.body, hasLength(2));
166-
});
162+
expect(response.body, hasLength(2));
163+
});
167164

168-
test('updateRecipe', () async {
169-
final recipe = cookbook.RecipeBuilder()
170-
..name = 'My super cool recipe'
171-
..dateCreated = DateTime.utc(2023).toIso8601String();
172-
final createResponse = await tester.client.cookbook.recipes.newRecipe($body: recipe.build());
173-
addTearDown(() async {
174-
closeFixture();
175-
await tester.client.cookbook.recipes.deleteRecipe(id: createResponse.body.toString());
176-
});
177-
expect(createResponse.body, isNotNull);
178-
179-
recipe
180-
..id = createResponse.body.toString()
181-
..name = 'My updated super cool recipe';
182-
final updateResponse = await tester.client.cookbook.recipes
183-
.updateRecipe(id: createResponse.body.toString(), $body: recipe.build());
184-
expect(updateResponse.body, isNotNull);
185-
});
165+
test('updateRecipe', () async {
166+
final recipe = cookbook.RecipeBuilder()
167+
..name = 'My super cool recipe'
168+
..dateCreated = DateTime.utc(2023).toIso8601String();
169+
final createResponse = await tester.client.cookbook.recipes.newRecipe($body: recipe.build());
170+
addTearDown(() async {
171+
closeFixture();
172+
await tester.client.cookbook.recipes.deleteRecipe(id: createResponse.body.toString());
173+
});
174+
expect(createResponse.body, isNotNull);
175+
176+
recipe
177+
..id = createResponse.body.toString()
178+
..name = 'My updated super cool recipe';
179+
final updateResponse = await tester.client.cookbook.recipes
180+
.updateRecipe(id: createResponse.body.toString(), $body: recipe.build());
181+
expect(updateResponse.body, isNotNull);
186182
});
183+
});
187184

188-
group('tags', () {
189-
test('listKeywords', () async {
190-
final response = await tester.client.cookbook.tags.listKeywords();
185+
group('tags', () {
186+
test('listKeywords', () async {
187+
final response = await tester.client.cookbook.tags.listKeywords();
191188

192-
expect(response.body, hasLength(16));
193-
});
189+
expect(response.body, hasLength(16));
190+
});
194191

195-
test('recipesWithKeyword', () async {
196-
final response = await tester.client.cookbook.tags.recipesWithKeyword(keywords: 'Desserts');
192+
test('recipesWithKeyword', () async {
193+
final response = await tester.client.cookbook.tags.recipesWithKeyword(keywords: 'Desserts');
197194

198-
expect(response.body, hasLength(0));
199-
});
195+
expect(response.body, hasLength(0));
200196
});
201-
},
202-
retry: retryCount,
203-
timeout: timeout,
204-
);
197+
});
198+
});
205199
}

0 commit comments

Comments
 (0)