Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

chore: Added 9 tests to socket_test.dart #4

Merged
merged 13 commits into from Nov 17, 2020

Conversation

hardiksachan
Copy link
Contributor

What kind of change does this PR introduce?

Adds test to socket_test.dart

Tests added:

  • disconnect

    • calls connection close callback
    • does not throw when no connection
  • channel

    • returns channel with given topic and params
    • adds channel to sockets channels list
  • remove

    • removes given channel from channels
  • push

    • sends data to connection when connected
    • buffers data when not connected
  • makeRef

    • returns next message ref
    • restarts for overflow

hardiksachan and others added 9 commits November 14, 2020 01:00
Tests added:
    - constructor
        - sets defaults
        - overrides some defaults with options

    - endpointURL
        - returns endpoint for given full url
        - returns endpoint with parameters
        - returns endpoint with apikey

    - connect with Websocket
        - establishes websocket connection with endpoint
        - sets callbacks for connection
        - is idempotent

    - disconnect
        - removes existing connection
        - calls callback
Main codebase updated.
Tests added:
    - disconnect
        - calls connection close callback
        - does not throw when no connection

    - channel
        - returns channel with given topic and params
        - adds channel to sockets channels list

    - remove
        - removes given channel from channels

    - push
        - sends data to connection when connected
        - buffers data when not connected

    - makeRef
        - returns next message ref
        - restarts for overflow
Added tests

    - sendHeartbeat
        - pushes heartbeat data when connected
        - no ops when not connected
@hardiksachan
Copy link
Contributor Author

EDIT 1: Added 2 more tests

Adds test to socket_test.dart

Tests added:

  • sendHeartbeat
    • pushes heartbeat data when connected
    • no ops when not connected

@phamhieu
Copy link
Member

@hardiksachan nice work!! Thanks you

There's a failed test. Can you help check.
Screenshot 2020-11-17 at 11 26 50 AM

@hardiksachan
Copy link
Contributor Author

You will need to update makeRef(). Something like this

String makeRef() {
    const int int64MaxValue = 9223372036854775807;
    int newRef;
    if (ref == int64MaxValue) {
      newRef = 0;
    } else {
      newRef = ref + 1;
    }
    ref = newRef;

    return ref.toString();
  }

@phamhieu
Copy link
Member

You will need to update makeRef(). Something like this

String makeRef() {
    const int int64MaxValue = 9223372036854775807;
    int newRef;
    if (ref == int64MaxValue) {
      newRef = 0;
    } else {
      newRef = ref + 1;
    }
    ref = newRef;

    return ref.toString();
  }

can you remove this test from this PR. Then create another PR with main code update for makeRef and the test-case.

@hardiksachan
Copy link
Contributor Author

Yeah! Sure.

@hardiksachan
Copy link
Contributor Author

Hey, can you look at the failed test case. I have no idea why it is failing.

pubspec.lock Outdated Show resolved Hide resolved
test/socket_test.dart Outdated Show resolved Hide resolved
@phamhieu phamhieu merged commit a820c59 into supabase:main Nov 17, 2020
@hardiksachan hardiksachan deleted the test-socket branch November 17, 2020 07:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants