Skip to content

Commit

Permalink
Fix issue with desktop test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Dec 2, 2024
1 parent 0f7a5c7 commit ebc6743
Show file tree
Hide file tree
Showing 12 changed files with 451 additions and 296 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
run: make ci-android-test

- name: Running workflow test for macos
run: make desktopWorkflowTest
run: make maOSWorkflowTest
if: runner.os == 'macOS'
timeout-minutes: 60

Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,16 @@ windowsDesktopTest:
sh $(CURDIR)/integration_test/run_windows_test.sh

# Run specific tests on desktop
#you can pass DEVICE=<platform> (e.g., macOS, linux, windows)
runDesktopTest:
@ARGUMENTS=$(filter-out $@,$(MAKECMDGOALS)); \
DEVICE=$(DEVICE); \
if [ -z "$$DEVICE" ]; then \
echo "Error: DEVICE is not specified. Use DEVICE=<platform> (e.g., macOS, linux, android)"; \
exit 1; \
fi; \
echo "Running tests on: $$ARGUMENTS" && \
flutter test $$ARGUMENTS -d macOS -r expanded
flutter test $$ARGUMENTS -d $$DEVICE -r expanded


# Run all android test on Firebase test lab
Expand Down
303 changes: 204 additions & 99 deletions README.md

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions integration_test/run_macos_test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
# Find all _test.dart files in the integration_test directory and its immediate subdirectories

all_tests_passed=true

# Find all _test.dart files and iterate over them
find integration_test -maxdepth 4 -type f -name '*_test.dart' | while read test_file; do
flutter test "$test_file" -d macOS
echo "Running test: $test_file"
flutter test "$test_file" -d macOS -r github
if [ $? -ne 0 ]; then
echo "Test $test_file failed."
exit 1
all_tests_passed=false
else
echo "Test $test_file passed."
fi
done

# Fail the script if any test failed
if [ "$all_tests_passed" = false ]; then
echo "One or more tests failed."
exit 1
else
echo "All tests passed successfully."
exit 0
fi
367 changes: 188 additions & 179 deletions internalsdk/protos/vpn.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internalsdk/session_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ func (m *SessionModel) BandwidthUpdate(p1 int, p2 int, p3 int, p4 int) error {
Percent: int64(p1),
MibUsed: int64(p2),
MibAllowed: int64(p3),
TtlSeconds: int64(p4),
TTLSeconds: int64(p4),
}
return pathdb.Mutate(m.db, func(tx pathdb.TX) error {
return pathdb.Put(tx, pathBandwidth, bandwidth, "")
Expand Down
2 changes: 2 additions & 0 deletions internalsdk/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func TestCreateUser_Success(t *testing.T) {
Token: "test-token",
},
}, nil)

mockSession.On("GetUserData", int64(123)).Return(nil)
mockSession.On("SetUserIdAndToken", int64(123), "test-token").Return(nil)

err := createUser(context.Background(), mockProClient, mockSession)
Expand Down
2 changes: 1 addition & 1 deletion internalsdk/vpn_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (m *VPNModel) UpdateBandwidth(percent int64, mibUsed int64, mibAllowed int6
Percent: percent,
MibUsed: mibUsed,
MibAllowed: mibAllowed,
TtlSeconds: ttlSeconds,
TTLSeconds: ttlSeconds,
}
return pathdb.Put(tx, pathBandwidth, bandwidth, "")
})
Expand Down
1 change: 1 addition & 0 deletions lib/core/service/websocket_subscriber.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class WebsocketSubscriber {

case _WebsocketMessageType.bandwidth:
_webSocketLogger.i("Websocket message[Bandwidth]: $message");
// final bandwidth = message as Map<String, dynamic>;
sessionModel.bandwidthNotifier.value = Bandwidth.create()
..mergeFromProto3Json(message);
case _WebsocketMessageType.config:
Expand Down
30 changes: 22 additions & 8 deletions lib/features/vpn/protos_shared/vpn.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class Bandwidth extends $pb.GeneratedMessage {
$fixnum.Int64? percent,
$fixnum.Int64? mibUsed,
$fixnum.Int64? mibAllowed,
$fixnum.Int64? ttlSeconds,
$fixnum.Int64? tTLSeconds,
$core.String? asOf,
}) {
final $result = create();
if (percent != null) {
Expand All @@ -109,8 +110,11 @@ class Bandwidth extends $pb.GeneratedMessage {
if (mibAllowed != null) {
$result.mibAllowed = mibAllowed;
}
if (ttlSeconds != null) {
$result.ttlSeconds = ttlSeconds;
if (tTLSeconds != null) {
$result.tTLSeconds = tTLSeconds;
}
if (asOf != null) {
$result.asOf = asOf;
}
return $result;
}
Expand All @@ -122,7 +126,8 @@ class Bandwidth extends $pb.GeneratedMessage {
..aInt64(1, _omitFieldNames ? '' : 'percent')
..aInt64(2, _omitFieldNames ? '' : 'mibUsed', protoName: 'mibUsed')
..aInt64(3, _omitFieldNames ? '' : 'mibAllowed', protoName: 'mibAllowed')
..aInt64(4, _omitFieldNames ? '' : 'ttlSeconds', protoName: 'ttlSeconds')
..aInt64(4, _omitFieldNames ? '' : 'TTLSeconds', protoName: 'TTLSeconds')
..aOS(5, _omitFieldNames ? '' : 'AsOf', protoName: 'AsOf')
..hasRequiredFields = false
;

Expand Down Expand Up @@ -175,13 +180,22 @@ class Bandwidth extends $pb.GeneratedMessage {
void clearMibAllowed() => clearField(3);

@$pb.TagNumber(4)
$fixnum.Int64 get ttlSeconds => $_getI64(3);
$fixnum.Int64 get tTLSeconds => $_getI64(3);
@$pb.TagNumber(4)
set ttlSeconds($fixnum.Int64 v) { $_setInt64(3, v); }
set tTLSeconds($fixnum.Int64 v) { $_setInt64(3, v); }
@$pb.TagNumber(4)
$core.bool hasTtlSeconds() => $_has(3);
$core.bool hasTTLSeconds() => $_has(3);
@$pb.TagNumber(4)
void clearTtlSeconds() => clearField(4);
void clearTTLSeconds() => clearField(4);

@$pb.TagNumber(5)
$core.String get asOf => $_getSZ(4);
@$pb.TagNumber(5)
set asOf($core.String v) { $_setString(4, v); }
@$pb.TagNumber(5)
$core.bool hasAsOf() => $_has(4);
@$pb.TagNumber(5)
void clearAsOf() => clearField(5);
}

class AppData extends $pb.GeneratedMessage {
Expand Down
7 changes: 4 additions & 3 deletions lib/features/vpn/protos_shared/vpn.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ const Bandwidth$json = {
{'1': 'percent', '3': 1, '4': 1, '5': 3, '10': 'percent'},
{'1': 'mibUsed', '3': 2, '4': 1, '5': 3, '10': 'mibUsed'},
{'1': 'mibAllowed', '3': 3, '4': 1, '5': 3, '10': 'mibAllowed'},
{'1': 'ttlSeconds', '3': 4, '4': 1, '5': 3, '10': 'ttlSeconds'},
{'1': 'TTLSeconds', '3': 4, '4': 1, '5': 3, '10': 'TTLSeconds'},
{'1': 'AsOf', '3': 5, '4': 1, '5': 9, '10': 'AsOf'},
],
};

/// Descriptor for `Bandwidth`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List bandwidthDescriptor = $convert.base64Decode(
'CglCYW5kd2lkdGgSGAoHcGVyY2VudBgBIAEoA1IHcGVyY2VudBIYCgdtaWJVc2VkGAIgASgDUg'
'dtaWJVc2VkEh4KCm1pYkFsbG93ZWQYAyABKANSCm1pYkFsbG93ZWQSHgoKdHRsU2Vjb25kcxgE'
'IAEoA1IKdHRsU2Vjb25kcw==');
'dtaWJVc2VkEh4KCm1pYkFsbG93ZWQYAyABKANSCm1pYkFsbG93ZWQSHgoKVFRMU2Vjb25kcxgE'
'IAEoA1IKVFRMU2Vjb25kcxISCgRBc09mGAUgASgJUgRBc09m');

@$core.Deprecated('Use appDataDescriptor instead')
const AppData$json = {
Expand Down
3 changes: 2 additions & 1 deletion protos_shared/vpn.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ message Bandwidth {
int64 percent = 1; // [0, 100]
int64 mibUsed = 2; // in MB
int64 mibAllowed = 3; // in MB
int64 ttlSeconds = 4; // number of seconds left before data reset
int64 TTLSeconds = 4; // number of seconds left before data reset
string AsOf =5;
}

message AppData {
Expand Down

0 comments on commit ebc6743

Please sign in to comment.