▍ humdrum codex / custard v0.3.0
license AGPL-3.0
1.4 KB raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package cli

import "testing"

func TestDeployURL(t *testing.T) {
	cases := []struct {
		name string
		out  string
		want string
	}{
		{
			name: "vercel json picks vercel.app not api",
			out: `Deploying humdrumone/guilds
  Inspect    https://vercel.com/humdrumone/guilds/GybubpArrMaKQALBaSct613mdJGq
  Preview    https://guilds-ivafhzmbb-humdrumone.vercel.app
{
  "deployment": {
    "url": "https://guilds-ivafhzmbb-humdrumone.vercel.app",
    "inspectorUrl": "https://vercel.com/humdrumone/guilds/GybubpArrMaKQALBaSct613mdJGq",
    "deploymentApiUrl": "https://api.vercel.com/v13/deployments/dpl_GybubpArrMaKQALBaSct613mdJGq"
  }
}`,
			want: "https://guilds-ivafhzmbb-humdrumone.vercel.app",
		},
		{
			name: "trailing quote and comma stripped",
			out:  `{"url": "https://example.vercel.app",}`,
			want: "https://example.vercel.app",
		},
		{
			name: "non-vercel tool returns last url",
			out:  "Deployed to https://my-site.netlify.app",
			want: "https://my-site.netlify.app",
		},
		{
			name: "custom domain on vercel is kept",
			out: `  Inspect  https://vercel.com/humdrumone/guilds/abc
Success! https://guilds.quest`,
			want: "https://guilds.quest",
		},
		{
			name: "no url",
			out:  "nothing here",
			want: "",
		},
	}
	for _, c := range cases {
		t.Run(c.name, func(t *testing.T) {
			if got := deployURL(c.out); got != c.want {
				t.Errorf("deployURL() = %q, want %q", got, c.want)
			}
		})
	}
}