Skip to content

Commit

Permalink
moved test
Browse files Browse the repository at this point in the history
  • Loading branch information
vpandiarajan20 committed Dec 2, 2024
1 parent 886a4ef commit d46d0bf
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions test/unit_test/app/data_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,31 @@ void main() {
.removeBinaryDataFromDatasetByIds([BinaryID(fileId: 'fileId', organizationId: 'orgId', locationId: 'locId')], 'dataset');
verify(serviceClient.removeBinaryDataFromDatasetByIDs(any)).called(1);
});
test('getLatestTabularData', () async {
final timeCaptured = DateTime(2023, 1, 1);
final timeSynced = DateTime(2023, 1, 2);
final payload = Struct()..fields.addAll({'key': Value()..stringValue = 'value'});

when(dataServiceClient.getLatestTabularData(any)).thenAnswer((_) => MockResponseFuture.value(GetLatestTabularDataResponse()
..timeCaptured = Timestamp.fromDateTime(timeCaptured)
..timeSynced = Timestamp.fromDateTime(timeSynced)
..payload = payload));

final response = await dataClient.getLatestTabularData('part-id', 'resource-name', 'resource-subtype', 'method-name');

expect(response?.$1, equals(timeCaptured));
expect(response?.$2, equals(timeSynced));
expect(response?.$3, equals({'key': 'value'}));

verify(dataServiceClient.getLatestTabularData(any)).called(1);

// Test null response
when(dataServiceClient.getLatestTabularData(any)).thenAnswer((_) => MockResponseFuture.value(GetLatestTabularDataResponse()));

final nullResponse = await dataClient.getLatestTabularData('part-id', 'resource-name', 'resource-subtype', 'method-name');

expect(nullResponse, isNull);
});
});

group('DataSync Tests', () {
Expand Down Expand Up @@ -409,34 +434,12 @@ void main() {
final response = await dataClient.listDatasetsByIDs(['dataset-id']);
expect(response, equals(expected));
});
});
});

test('getLatestTabularData', () async {
final timeCaptured = DateTime(2023, 1, 1);
final timeSynced = DateTime(2023, 1, 2);
final payload = Struct()..fields.addAll({'key': Value()..stringValue = 'value'});

when(dataServiceClient.getLatestTabularData(any)).thenAnswer((_) => MockResponseFuture.value(GetLatestTabularDataResponse()
..timeCaptured = Timestamp.fromDateTime(timeCaptured)
..timeSynced = Timestamp.fromDateTime(timeSynced)
..payload = payload));

final response = await dataClient.getLatestTabularData('part-id', 'resource-name', 'resource-subtype', 'method-name');

expect(response?.$1, equals(timeCaptured));
expect(response?.$2, equals(timeSynced));
expect(response?.$3, equals({'key': 'value'}));

verify(dataServiceClient.getLatestTabularData(any)).called(1);

// Test null response
when(dataServiceClient.getLatestTabularData(any)).thenAnswer((_) => MockResponseFuture.value(GetLatestTabularDataResponse()));
});
});

final nullResponse = await dataClient.getLatestTabularData('part-id', 'resource-name', 'resource-subtype', 'method-name');

expect(nullResponse, isNull);
});

group('Filter Utils Tests', () {
test('setDateTimeCaptureInterval', () {
Expand Down

0 comments on commit d46d0bf

Please sign in to comment.