carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package console
2
3import (
4 "testing"
5)
6
7func TestReleaseSummary(t *testing.T) {
8 chans := []ChannelView{
9 {Name: "stable", Version: "d388035", Actor: "paul@keymail.dev"},
10 {Name: "beta", Version: "e91ac22"},
11 {Name: "canary/rc-1", Version: "aaa1111"},
12 }
13 routes := []RouteView{{Host: "edge.example", Account: "bab", Channel: "edge", Version: "route-v"}}
14 s := assembleReleaseSummary(chans, routes, "bab")
15 if !s.Deployment.HasReportedVersion() || s.Deployment.UniformVersion() != "route-v" {
16 t.Errorf("live = %+v", s)
17 }
18 if s.NextVersion != "e91ac22" {
19 t.Errorf("next = %+v", s)
20 }
21
22 same := assembleReleaseSummary([]ChannelView{
23 {Name: "stable", Version: "v1"}, {Name: "beta", Version: "v1"},
24 }, []RouteView{{Host: "x", Account: "bab", Version: "v1"}}, "bab")
25 if same.NextVersion != "" {
26 t.Errorf("same version on beta must not be Next, got %q", same.NextVersion)
27 }
28
29 bad := assembleReleaseSummary([]ChannelView{{Name: "stable", Err: "boom"}, {Name: "beta", Version: "v2"}}, routes, "bab")
30 if !bad.Deployment.HasReportedVersion() || bad.Deployment.UniformVersion() != "route-v" || bad.NextVersion != "" {
31 t.Errorf("unreadable target changed observed deployment = %+v", bad)
32 }
33}
34