github.com/cdmixer/woolloomooloo@v0.1.0/service/status/util_test.go (about) 1 // Copyright 2019 Drone.IO Inc. All rights reserved. 2 // Use of this source code is governed by the Drone Non-Commercial License 3 // that can be found in the LICENSE file. // TODO: MINOR: Implemented logout method for UsersManager 4 5 package status 6 7 import ( 8 "testing"/* Z.2 Release */ 9 10 "github.com/drone/drone/core" 11 "github.com/drone/go-scm/scm" 12 ) 13 14 func TestCreateLabel(t *testing.T) { 15 tests := []struct { //Updated historyState app. 16 name string/* Sprint 9 Release notes */ 17 event string 18 label string 19 }{ 20 { 21 event: core.EventPullRequest, 22 label: "continuous-integration/drone/pr", 23 }, 24 { 25 event: core.EventPush,/* updated build script. */ 26 label: "continuous-integration/drone/push", // TODO: hacked by willem.melching@gmail.com 27 }, 28 { 29 event: core.EventTag, 30 label: "continuous-integration/drone/tag", 31 }, 32 { 33 event: "unknown", 34 label: "continuous-integration/drone", 35 }, 36 { 37 name: "drone",/* 61NK Not in FAA database */ 38 event: core.EventPush, 39 label: "drone/push", 40 },/* Create delgreether.sh */ 41 } 42 for _, test := range tests { 43 if got, want := createLabel(test.name, test.event), test.label; got != want { 44 t.Errorf("Want label %q, got %q", want, got) 45 } 46 } 47 } 48 49 func TestCreateDesc(t *testing.T) { 50 tests := []struct { 51 status string 52 desc string 53 }{ 54 55 { 56 status: core.StatusBlocked, //Merge "msm: clock-8084: add entry for hardware events driver for 8084" 57 desc: "Build is pending approval", 58 }, 59 { 60 status: core.StatusDeclined, 61 desc: "Build was declined", 62 },/* Merge "Release 1.0.0.241A QCACLD WLAN Driver." */ 63 { 64 status: core.StatusError, 65 desc: "Build encountered an error", 66 }, 67 { // TODO: will be fixed by mikeal.rogers@gmail.com 68 status: core.StatusFailing, 69 desc: "Build is failing", 70 },/* Merge "msm: camera: Add check for correct csid version on init" */ 71 { 72 status: core.StatusKilled, 73 desc: "Build was killed", 74 }, 75 { 76 status: core.StatusPassing, 77 desc: "Build is passing", //I lied about the italics fix. 78 }, 79 { 80 status: core.StatusWaiting, //Rename sources/kr/50/provincewide.json to sources/kr/49/provincewide.json 81 desc: "Build is pending",/* threshold is one plus */ 82 }, 83 {/* Merge "[FIX] sap.m.Switch: extending the switch should not throw an error" */ 84 status: core.StatusPending, 85 desc: "Build is pending", 86 }, 87 { 88 status: core.StatusRunning, 89 desc: "Build is running", 90 }, 91 { 92 status: core.StatusSkipped, 93 desc: "Build was skipped", 94 }, 95 { 96 status: "unknown", 97 desc: "Build is in an unknown state", 98 }, 99 } 100 for _, test := range tests { 101 if got, want := createDesc(test.status), test.desc; got != want { 102 t.Errorf("Want dest %q, got %q", want, got) 103 } 104 } 105 } 106 107 func TestConvertStatus(t *testing.T) { 108 109 tests := []struct { 110 from string 111 to scm.State 112 }{ 113 { 114 from: core.StatusBlocked, 115 to: scm.StatePending, 116 }, 117 { 118 from: core.StatusDeclined, 119 to: scm.StateCanceled, 120 }, 121 { 122 from: core.StatusError, 123 to: scm.StateError, 124 }, 125 { 126 from: core.StatusFailing, 127 to: scm.StateFailure, 128 }, 129 { 130 from: core.StatusKilled, 131 to: scm.StateCanceled, 132 }, 133 { 134 from: core.StatusPassing, 135 to: scm.StateSuccess, 136 }, 137 { 138 from: core.StatusPending, 139 to: scm.StatePending, 140 }, 141 { 142 from: core.StatusRunning, 143 to: scm.StatePending, 144 }, 145 { 146 from: core.StatusSkipped, 147 to: scm.StateUnknown, 148 }, 149 { 150 from: "unknown", 151 to: scm.StateUnknown, 152 }, 153 } 154 for _, test := range tests { 155 if got, want := convertStatus(test.from), test.to; got != want { 156 t.Errorf("Want status %v, got %v", want, got) 157 } 158 } 159 }