Skip to content

Commit 1da102b

Browse files
authored
fix: filter tasks by Organization ID (#287)
1 parent ec8daa2 commit 1da102b

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Changed type of `Duration.magnitude` from `int?` to `long?`.
66
### Features
77
1. [#282](https://github.com/influxdata/influxdb-client-csharp/pull/282): Add support for AggregateWindow function [LINQ]
88

9+
### Bug Fixes
10+
1. [#287](https://github.com/influxdata/influxdb-client-csharp/pull/287): Filter tasks by Organization ID
11+
912
## 3.3.0 [2022-02-04]
1013

1114
### Bug Fixes

Client.Test/ItTasksApiTest.cs

+14-26
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ public async Task FindTasks()
262262
}
263263

264264
[Test]
265-
[Ignore("https://github.com/influxdata/influxdb/issues/13577")]
266265
public async Task FindTasksAfterSpecifiedId()
267266
{
268267
var task1 = await _tasksApi.CreateTaskCronAsync(GenerateName("it task"), TaskFlux, "0 2 * * *", _organization);
@@ -275,44 +274,33 @@ public async Task FindTasksAfterSpecifiedId()
275274
}
276275

277276
[Test]
278-
[Ignore("https://github.com/influxdata/influxdb/issues/11491")]
279-
//_token
280277
public async Task FindTasksByOrganization()
281278
{
282-
var taskOrg = await Client.GetOrganizationsApi().CreateOrganizationAsync(GenerateName("Task user"));
283-
var authorization = await AddAuthorization(taskOrg);
284-
285-
Client.Dispose();
286-
Client = InfluxDBClientFactory.Create(InfluxDbUrl, authorization.Token);
287-
_tasksApi = Client.GetTasksApi();
288-
289-
var count = (await _tasksApi.FindTasksByOrganizationAsync(taskOrg)).Count;
290-
Assert.AreEqual(0, count);
291-
292-
await _tasksApi.CreateTaskCronAsync(GenerateName("it task"), TaskFlux, "0 2 * * *", taskOrg);
293-
294-
var tasks = await _tasksApi.FindTasksByOrganizationAsync(taskOrg);
279+
var count = (await _tasksApi.FindTasksByOrganizationAsync(_organization)).Count;
280+
Assert.GreaterOrEqual(count, 0);
295281

296-
Assert.AreEqual(1, tasks.Count);
282+
await _tasksApi.CreateTaskCronAsync(GenerateName("it task"), TaskFlux, "0 2 * * *", _organization);
297283

298-
(await _tasksApi.FindTasksAsync()).ForEach(async task => await _tasksApi.DeleteTaskAsync(task));
284+
var tasks = await _tasksApi.FindTasksByOrganizationAsync(_organization);
285+
Assert.AreEqual(count + 1, tasks.Count);
299286
}
300287

301288
[Test]
302-
//_token
303-
[Ignore("set user password -> https://github.com/influxdata/influxdb/issues/11590")]
304289
public async Task FindTasksByUser()
305290
{
306-
var taskUser = await Client.GetUsersApi().CreateUserAsync(GenerateName("Task user"));
291+
Client.Dispose();
292+
Client = InfluxDBClientFactory.Create(InfluxDbUrl, "my-user", "my-password".ToCharArray());
293+
_tasksApi = Client.GetTasksApi();
294+
295+
var user = (await Client.GetUsersApi().FindUsersAsync(name:"my-user"))[0];
307296

308-
var count = (await _tasksApi.FindTasksByUserAsync(taskUser)).Count;
309-
Assert.AreEqual(0, count);
297+
var count = (await _tasksApi.FindTasksByUserAsync(user)).Count;
298+
Assert.GreaterOrEqual(count, 0);
310299

311300
await _tasksApi.CreateTaskCronAsync(GenerateName("it task"), TaskFlux, "0 2 * * *", _organization);
312301

313-
var tasks = await _tasksApi.FindTasksByUserAsync(taskUser);
314-
315-
Assert.AreEqual(1, tasks.Count);
302+
var tasks = await _tasksApi.FindTasksByUserAsync(user);
303+
Assert.AreEqual(count + 1, tasks.Count);
316304
}
317305

318306
[Test]

Client/TasksApi.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ public Task<List<TaskType>> FindTasksByOrganizationIdAsync(string orgId)
314314
/// <returns>A list of tasks</returns>
315315
public async Task<List<TaskType>> FindTasksAsync(string afterId = null, string userId = null, string orgId = null)
316316
{
317-
var response = await _service.GetTasksAsync(null, null, afterId, userId, orgId).ConfigureAwait(false);
317+
var response = await _service.GetTasksAsync(after: afterId, user: userId, orgID: orgId)
318+
.ConfigureAwait(false);
318319
return response._Tasks;
319320
}
320321

0 commit comments

Comments
 (0)