vscode_test.dart 853 Bytes
Newer Older
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// @dart = 2.8

7 8 9 10
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/version.dart';
import 'package:flutter_tools/src/vscode/vscode.dart';

11
import '../../src/common.dart';
12 13

void main() {
14 15
  testWithoutContext('VsCode.fromDirectory does not crash when packages.json is malformed', () {
    final MemoryFileSystem fileSystem = MemoryFileSystem.test();
16
    // Create invalid JSON file.
17
    fileSystem.file(fileSystem.path.join('', 'resources', 'app', 'package.json'))
18 19 20
      ..createSync(recursive: true)
      ..writeAsStringSync('{');

21
    final VsCode vsCode = VsCode.fromDirectory('', '', fileSystem: fileSystem);
22 23 24 25

    expect(vsCode.version, Version.unknown);
  });
}