template_test.dart 1023 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/template.dart';
7
import 'package:flutter_tools/src/globals.dart' as globals;
8 9 10 11 12 13 14 15 16 17 18 19 20
import 'package:mockito/mockito.dart';

import 'src/common.dart';
import 'src/testbed.dart';

void main() {
  Testbed testbed;

  setUp(() {
    testbed = Testbed();
  });

  test('Template.render throws ToolExit when FileSystem exception is raised', () => testbed.run(() {
21
    final Template template = Template(globals.fs.directory('examples'), globals.fs.currentDirectory);
22 23 24 25
    final MockDirectory mockDirectory = MockDirectory();
    when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());

    expect(() => template.render(mockDirectory, <String, Object>{}),
Dan Field's avatar
Dan Field committed
26
        throwsToolExit());
27 28 29 30
  }));
}

class MockDirectory extends Mock implements Directory {}