Skip to content

Commit

Permalink
chore: add unit test for cred provider
Browse files Browse the repository at this point in the history
  • Loading branch information
bruuuuuuuce committed Dec 15, 2023
1 parent 27ccd27 commit 9fbb954
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 108 deletions.
21 changes: 6 additions & 15 deletions lib/src/auth/credential_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,10 @@ class _ParsedApiKey {
_ParsedApiKey(this.apiKey, this.controlEndpoint, this.cacheEndpoint);
}

class _Base64DecodedV1Token {
String apiKey;
String endpoint;
_Base64DecodedV1Token(this.apiKey, this.endpoint);
}

abstract class CredentialProvider {
String _apiKey;
String _controlEndpoint;
String _cacheEndpoint;
final String _apiKey;
final String _controlEndpoint;
final String _cacheEndpoint;
CredentialProvider(this._apiKey, this._controlEndpoint, this._cacheEndpoint);
String get apiKey => _apiKey;
String get controlEndpoint => _controlEndpoint;
Expand Down Expand Up @@ -110,16 +104,13 @@ class StringMomentoTokenProvider implements CredentialProvider {
}

@override
// TODO: implement apiKey
String get apiKey => throw UnimplementedError();
String get apiKey => _apiKey;

@override
// TODO: implement cacheEndpoint
String get cacheEndpoint => throw UnimplementedError();
String get cacheEndpoint => _cacheEndpoint;

@override
// TODO: implement controlEndpoint
String get controlEndpoint => throw UnimplementedError();
String get controlEndpoint => _controlEndpoint;

}

Expand Down
62 changes: 31 additions & 31 deletions lib/src/client_sdk_dart_base.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
// TODO: Put public facing types in this file.

import '../generated/cachepubsub.pb.dart';
import 'package:grpc/grpc.dart';

abstract class ITopicClient {
void publish();
}

class TopicClient implements ITopicClient {
ClientChannel _channel;
TopicClient() {
_channel = ClientChannel(host)
}
@override
void publish() {
// TODO: implement publish
}

void close() {

}
}

/// Checks if you are awesome. Spoiler: you are.
class Awesome {
bool get isAwesome => true;
}

PubsubApi api = PubsubApi();
// // TODO: Put public facing types in this file.
//
// import '../generated/cachepubsub.pb.dart';
// import 'package:grpc/grpc.dart';
//
// abstract class ITopicClient {
// void publish();
// }
//
// class TopicClient implements ITopicClient {
// ClientChannel _channel;
//
// TopicClient() {
// _channel = ClientChannel(host)
// }
// @override
// void publish() {
// // TODO: implement publish
// }
//
// void close() {
//
// }
// }
//
// /// Checks if you are awesome. Spoiler: you are.
// class Awesome {
// bool get isAwesome => true;
// }
//
// PubsubApi api = PubsubApi();
90 changes: 44 additions & 46 deletions lib/src/topic_client.dart
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
// TODO: Put public facing types in this file.

import 'dart:typed_data';

import '../generated/cachepubsub.pb.dart';
import 'package:grpc/grpc.dart';

sealed class Value {}
class StringValue implements Value {
String _value;
StringValue(String v) : _value = v;
String get value => _value;
}

class BinaryValue implements Value {
Uint8List _value;
BinaryValue(Uint8List v) : _value = v;
Uint8List get value => _value;
}

abstract class ITopicClient {
void publish(String cacheName, String topicName, Value value);
}

class TopicClient implements ITopicClient {
ClientChannel _channel;

TopicClient() {
_channel = ClientChannel(host)
}
@override
void publish() {
// TODO: implement publish
}

void close() {

}
}

/// Checks if you are awesome. Spoiler: you are.
class Awesome {
bool get isAwesome => true;
}

PubsubApi api = PubsubApi();
// // TODO: Put public facing types in this file.
//
// import 'dart:typed_data';
//
// import '../generated/cachepubsub.pb.dart';
// import 'package:grpc/grpc.dart';
//
// sealed class Value {}
// class StringValue implements Value {
// String _value;
// StringValue(String v) : _value = v;
// String get value => _value;
// }
//
// class BinaryValue implements Value {
// Uint8List _value;
// BinaryValue(Uint8List v) : _value = v;
// Uint8List get value => _value;
// }
//
// abstract class ITopicClient {
// void publish(String cacheName, String topicName, Value value);
// }
//
// class TopicClient implements ITopicClient {
// ClientChannel _channel;
//
// TopicClient() {
// _channel = ClientChannel(host)
// }
// @override
// void publish() {
// // TODO: implement publish
// }
//
// void close() {
//
// }
// }
//
// /// Checks if you are awesome. Spoiler: you are.
// class Awesome {
// bool get isAwesome => true;
// }
16 changes: 0 additions & 16 deletions test/client_sdk_dart_test.dart

This file was deleted.

17 changes: 17 additions & 0 deletions test/src/auth/credential_provider_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:client_sdk_dart/client_sdk_dart.dart';
import 'package:client_sdk_dart/src/auth/credential_provider.dart';
import 'package:test/test.dart';

void main() {
group('credential_provider', () {
setUp(() {
// Additional setup goes here.
});

group("CredentialProvider.fromString", () => {
test('Test reading credentials from a string', () => {
CredentialProvider.fromString("")
})
});
});
}

0 comments on commit 9fbb954

Please sign in to comment.