Skip to content
Snippets Groups Projects
Select Git revision
  • master
1 result

maketn.py

Blame
  • location_test.dart 2.54 KiB
    import 'dart:io';
    
    import 'package:scp_meta/location.dart';
    import 'package:test/test.dart';
    
    void main() {
      group('SCP simple as [user@]host:[path]', () {
        test('SCP as user@host:path', () {
          Location location = Location('username@plzen1:etc/file.txt');
          expect(location.path, 'etc/file.txt');
          expect(location.user, 'username');
          expect(location.host, 'plzen1');
        });
    
        test('SCP as host:file', () {
          Location location = Location(
              'storage-plzen1.metacentrum.cz:etc/file.txt');
          expect(location.path, 'etc/file.txt');
          expect(location.user, null);
          expect(location.host, 'storage-plzen1.metacentrum.cz');
        });
    
        test('SCP as host:', () {
          Location location = Location('brno6.metacentrum.cz:');
          expect(location.path, null);
          expect(location.user, null);
          expect(location.host, 'brno6.metacentrum.cz');
        });
      });
    
      group('SCP URI as scp://[user@]host[:port][/path]', () {
        test('scp://user@host:port/path', () {
          Location location = Location('scp://_user-2@praha1:2222/tmp');
          expect(location.user, '_user-2');
          expect(location.host, 'praha1');
          expect(location.path, '/tmp');
          expect(location.port, '2222');
        });
    
        test('scp://user@host', () {
          Location location = Location('scp://123456@storage-brno2');
          expect(location.user, '123456');
          expect(location.host, 'storage-brno2');
          expect(location.path, null);
          expect(location.port, null);
        });
    
        test('scp://host', () {
          Location location = Location('scp://pruhonice1');
          expect(location.user, null);
          expect(location.host, 'pruhonice1');
          expect(location.path, null);
          expect(location.port, null);
        });
      });
    
      group('PATH', ()
      {
        test('absolute path as /.*', () {
          Location location = Location('/home/test/_list/.config');
          expect(location.user, null);
          expect(location.host, null);
          expect(location.path, '/home/test/_list/.config');
          expect(location.port, null);
        });
    
        test('relative path as .*', () {
          Location location = Location('../test/_file');
          expect(location.user, null);
          expect(location.host, null);