Skip to content
Snippets Groups Projects
Commit 7e4a09d3 authored by philenius's avatar philenius
Browse files

add unit tests for listBuckets()

parent 32f01fe9
Branches
Tags
No related merge requests found
/// Support for doing something awesome.
///
/// More dartdocs go here.
library minio;
export 'src/minio.dart';
export 'src/minio_errors.dart';
// TODO: Export any libraries intended for clients of this package.
import 'package:minio/minio.dart';
import 'package:test/test.dart';
void main() {
// group('A group of tests', () {
// Awesome awesome;
group('listBuckets', () {
test('listBuckets() succeeds', () async {
final minio = _getClient();
// setUp(() {
// awesome = Awesome();
// });
expect(() async => await minio.listBuckets(), returnsNormally);
});
// test('First Test', () {
// expect(awesome.isAwesome, isTrue);
// });
// });
test('listBuckets() fails due to wrong access key', () async {
final minio = _getClient(accessKey: 'incorrect-access-key');
expect(
() async => await minio.listBuckets(),
throwsA(
isA<MinioError>().having(
(e) => e.message,
'message',
'The Access Key Id you provided does not exist in our records.',
),
),
);
});
test('listBuckets() fails due to wrong secret key', () async {
final minio = _getClient(secretKey: 'incorrect-secret-key');
expect(
() async => await minio.listBuckets(),
throwsA(
isA<MinioError>().having(
(e) => e.message,
'message',
'The request signature we calculated does not match the signature you provided. Check your key and signing method.',
),
),
);
});
});
}
/// Initializes an instance of [Minio] with per default valid configuration.
///
/// Don't worry, these credentials for MinIO are publicly available and
/// connect only to the MinIO demo server at `play.minio.io`.
Minio _getClient({
String endpoint = 'play.minio.io',
int port = 443,
bool useSSL = true,
String accessKey = 'Q3AM3UQ867SPQQA43P2F',
String secretKey = 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
String sessionToken = '',
String region = 'us-east-1',
bool enableTrace = false,
}) =>
Minio(
endPoint: endpoint,
port: port,
useSSL: useSSL,
accessKey: accessKey,
secretKey: secretKey,
sessionToken: sessionToken,
region: region,
enableTrace: enableTrace,
);
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment