Skip to content

Commit

Permalink
refactor - downgrade sdk + lint versions && add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
msayed-net committed Jan 10, 2022
1 parent 0d72539 commit ba02fbe
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 39 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Dart CI - Test Coverage
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
defaults:
run:
working-directory: ./
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
flutter-version: "2.8.1"
channel: "stable"
- run: flutter pub get
- run: flutter test --coverage
- uses: codecov/[email protected]
- name: Very Good Coverage
uses: VeryGoodOpenSource/[email protected]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

- Improvements.

## 0.0.7

- Automated Release.
- Tests.

## 0.0.3 | 0.0.4 | 0.0.5 | 0.0.6

- release.
Expand Down
31 changes: 1 addition & 30 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
include: package:lint/analysis_options.yaml
25 changes: 25 additions & 0 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SF:lib/src/palestine_sms_misr_base.dart
DA:22,1
DA:30,1
DA:41,1
DA:45,2
DA:46,1
DA:47,5
DA:51,4
DA:54,1
DA:55,3
DA:68,1
DA:72,1
DA:74,2
DA:75,1
DA:76,6
DA:80,4
DA:83,1
DA:84,3
DA:92,1
DA:93,1
DA:94,3
DA:96,1
LF:21
LH:21
end_of_record
4 changes: 2 additions & 2 deletions example/palestine_sms_misr_example.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:palestine_sms_misr/palestine_sms_misr.dart';

void main() async {
PalSMSMisr palSMSMisr = PalSMSMisr(
Future<void> main() async {
final PalSMSMisr palSMSMisr = PalSMSMisr(
userName: 'xxxxxxxx',
password: 'xxxxxxxx',
senderName: 'xxxxx',
Expand Down
8 changes: 3 additions & 5 deletions lib/src/palestine_sms_misr_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ class PalSMSMisr {
required String phoneNumbers,
required String message,
}) async {
http.Response response = await http.post(
final http.Response response = await http.post(
Uri.parse(
'$baseURLMessage?username=$userName&password=$password&language=$language&sender=$senderName&mobile=$phoneNumbers&message=$message',
),
);

if (response.statusCode == 200 && response.body.contains('"1901"')) {
print(response.body);
return true;
} else {
developer.log(
Expand All @@ -70,16 +69,15 @@ class PalSMSMisr {
required String phoneNumber,
String? code,
}) async {
String _code = code ?? generateRandomNumbers();
final String _code = code ?? generateRandomNumbers();

http.Response response = await http.post(
final http.Response response = await http.post(
Uri.parse(
'$baseURLOTP?username=$userName&password=$password&msignature=$otpSignature&token=$otpToken&sender=$senderName&mobile=$phoneNumber&code=$_code',
),
);

if (response.statusCode == 200 && response.body.contains('"SMSID"')) {
print(response.body);
return code;
} else {
developer.log(
Expand Down
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: palestine_sms_misr
description: Lightweight SMS Misr gateway implementation in dart (unofficial).
version: 0.0.6
version: 0.0.7

homepage: https://github.com/msayed-net/PalestineDevelopers

environment:
sdk: ">=2.15.1 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
http: ^0.13.4

dev_dependencies:
lint: ^1.0.0
test: ^1.20.1
38 changes: 38 additions & 0 deletions test/palestine_sms_misr_base_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:palestine_sms_misr/palestine_sms_misr.dart';
import 'package:test/test.dart';

void main() {
final PalSMSMisr palSMSMisr = PalSMSMisr(
senderName: 'xxxx',
language: '2',
userName: 'user',
password: 'password',
otpToken: 'token12',
otpSignature: 'signature',
);

test('if can send message and OTP', () async {
expect(
await palSMSMisr.sendMessage(
phoneNumbers: '01004104004',
message: 'test message',
),
isFalse,
);
expect(
(await palSMSMisr.sendOTP(
phoneNumber: '01004104004',
code: '12012',
))
.runtimeType,
anyOf([String, Null]),
);
expect(
(await palSMSMisr.sendOTP(
phoneNumber: '01004104004',
))
.runtimeType,
anyOf([String, Null]),
);
});
}

0 comments on commit ba02fbe

Please sign in to comment.