// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_dashboard/logic/qualified_task.dart';
import 'package:flutter_dashboard/model/commit.pb.dart';
import 'package:flutter_dashboard/model/task.pb.dart';

import 'package:flutter_test/flutter_test.dart';

void main() {
  test('logUrl() for external tasks redirects to source configuration', () {
    final Task luciTask = Task()
      ..stageName = 'chromebot'
      ..name = 'abc'
      ..builderName = 'def';

    expect(logUrl(luciTask), 'https://ci.chromium.org/p/flutter/builders/luci.flutter.prod/def');
    final Task cirrusTask = Task()..stageName = 'cirrus';

    expect(
        logUrl(cirrusTask,
            commit: Commit()
              ..sha = 'abc123'
              ..branch = 'master'),
        'https://cirrus-ci.com/build/flutter/flutter/abc123?branch=master');

    expect(logUrl(cirrusTask), 'https://cirrus-ci.com/github/flutter/flutter/master');

    final Task googleTestTask = Task()..stageName = 'google_internal';
    expect(logUrl(googleTestTask), 'https://flutter-rob.corp.google.com');
  });

  test('QualifiedTask.sourceConfigurationUrl for luci', () {
    final Task luciTask = Task()
      ..stageName = 'chromebot'
      ..name = 'abc'
      ..builderName = 'def';

    expect(QualifiedTask.fromTask(luciTask).sourceConfigurationUrl,
        'https://ci.chromium.org/p/flutter/builders/luci.flutter.prod/def');
  });

  test('QualifiedTask.sourceConfigurationUrl for cirrus', () {
    final Task cirrusTask = Task()..stageName = 'cirrus';

    expect(QualifiedTask.fromTask(cirrusTask).sourceConfigurationUrl,
        'https://cirrus-ci.com/github/flutter/flutter/master');
  });

  test('QualifiedTask.sourceConfigurationUrl for google test', () {
    final Task googleTestTask = Task()..stageName = 'google_internal';

    expect(QualifiedTask.fromTask(googleTestTask).sourceConfigurationUrl, 'https://flutter-rob.corp.google.com');
  });

  test('QualifiedTask.isLuci', () {
    expect(const QualifiedTask(stage: 'luci', task: 'abc').isLuci, true);
    expect(const QualifiedTask(stage: 'chromebot', task: 'abc').isLuci, true);
    expect(const QualifiedTask(stage: 'cocoon', task: 'abc').isLuci, true);
    expect(const QualifiedTask(stage: 'cirrus', task: 'abc').isLuci, false);
    expect(const QualifiedTask(stage: 'google_internal', task: 'abc').isLuci, false);
  });
}
