| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package main | |
| 6 | |
| 7 import ( | |
| 8 "testing" | |
| 9 | |
| 10 "github.com/luci/luci-go/deploytool/api/deploy" | |
| 11 | |
| 12 . "github.com/smartystreets/goconvey/convey" | |
| 13 ) | |
| 14 | |
| 15 func TestCloudProjectVersion(t *testing.T) { | |
| 16 Convey(`A cloud project version`, t, func() { | |
| 17 b := cloudProjectVersionBuilder{ | |
| 18 currentUser: func() (string, error) { | |
| 19 return "test-person", nil | |
| 20 }, | |
| 21 } | |
| 22 cp := layoutDeploymentCloudProject{ | |
| 23 Deployment_CloudProject: &deploy.Deployment_CloudProject
{ | |
| 24 VersionScheme: deploy.Deployment_CloudProject_DE
FAULT, | |
| 25 }, | |
| 26 } | |
| 27 src := layoutSource{ | |
| 28 FrozenLayout_Source: &deploy.FrozenLayout_Source{ | |
| 29 MinorVersion: "--minor", | |
| 30 MajorVersion: "major", | |
| 31 }, | |
| 32 sg: &layoutSourceGroup{ | |
| 33 FrozenLayout_SourceGroup: &deploy.FrozenLayout_S
ourceGroup{}, | |
| 34 }, | |
| 35 } | |
| 36 | |
| 37 Convey(`Renders and parses without a tainted user.`, func() { | |
| 38 v, err := b.build(&cp, &src) | |
| 39 So(err, ShouldBeNil) | |
| 40 | |
| 41 s := v.String() | |
| 42 So(s, ShouldEqual, "__minor-major") | |
| 43 | |
| 44 parsed, err := parseCloudProjectVersion(deploy.Deploymen
t_CloudProject_DEFAULT, s) | |
| 45 So(err, ShouldBeNil) | |
| 46 So(parsed, ShouldResemble, v) | |
| 47 }) | |
| 48 | |
| 49 Convey(`Renders and parses with a tainted user.`, func() { | |
| 50 src.sg.Tainted = true | |
| 51 | |
| 52 v, err := b.build(&cp, &src) | |
| 53 So(err, ShouldBeNil) | |
| 54 | |
| 55 s := v.String() | |
| 56 So(s, ShouldEqual, "__minor-major-tainted-test_person") | |
| 57 | |
| 58 parsed, err := parseCloudProjectVersion(deploy.Deploymen
t_CloudProject_DEFAULT, s) | |
| 59 So(err, ShouldBeNil) | |
| 60 So(parsed, ShouldResemble, v) | |
| 61 }) | |
| 62 }) | |
| 63 } | |
| OLD | NEW |