BlueGit

timfa bluegit

Files

bluegit / internal / runner / git_safe_test.go

git_safe_test.go

fix: accepteer een checkout van een andere uid en toon het update-log
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
71de6a16 History
git_safe_test.go 1.6 KiB Download Raw
1package runner
2
3import "testing"
4
5func TestMarkWorkspaceSafeAppendsWithoutClobber(t *testing.T) {
6 empty := map[string]string{}
7 markWorkspaceSafe(empty)
8 if empty["GIT_CONFIG_COUNT"] != "1" || empty["GIT_CONFIG_KEY_0"] != "safe.directory" || empty["GIT_CONFIG_VALUE_0"] != "*" {
9 t.Fatalf("leeg: %+v", empty)
10 }
11
12 kept := map[string]string{
13 "GIT_CONFIG_COUNT": "1",
14 "GIT_CONFIG_KEY_0": "user.name",
15 "GIT_CONFIG_VALUE_0": "bluegit",
16 }
17 markWorkspaceSafe(kept)
18 if kept["GIT_CONFIG_COUNT"] != "2" || kept["GIT_CONFIG_KEY_0"] != "user.name" || kept["GIT_CONFIG_VALUE_0"] != "bluegit" {
19 t.Fatalf("eigen config weg: %+v", kept)
20 }
21 if kept["GIT_CONFIG_KEY_1"] != "safe.directory" || kept["GIT_CONFIG_VALUE_1"] != "*" {
22 t.Fatalf("safe.directory niet toegevoegd: %+v", kept)
23 }
24
25 star := map[string]string{
26 "GIT_CONFIG_COUNT": "1",
27 "GIT_CONFIG_KEY_0": "safe.directory",
28 "GIT_CONFIG_VALUE_0": "*",
29 }
30 markWorkspaceSafe(star)
31 if star["GIT_CONFIG_COUNT"] != "1" {
32 t.Fatalf("ster werd verdubbeld: %+v", star)
33 }
34
35 workspace := map[string]string{
36 "GIT_CONFIG_COUNT": "1",
37 "GIT_CONFIG_KEY_0": "safe.directory",
38 "GIT_CONFIG_VALUE_0": "/workspace",
39 }
40 markWorkspaceSafe(workspace)
41 if workspace["GIT_CONFIG_COUNT"] != "1" {
42 t.Fatalf("/workspace werd verdubbeld: %+v", workspace)
43 }
44
45 other := map[string]string{
46 "GIT_CONFIG_COUNT": "1",
47 "GIT_CONFIG_KEY_0": "safe.directory",
48 "GIT_CONFIG_VALUE_0": "/elsewhere",
49 }
50 markWorkspaceSafe(other)
51 if other["GIT_CONFIG_COUNT"] != "2" || other["GIT_CONFIG_VALUE_1"] != "*" {
52 t.Fatalf("ander pad dekt /workspace niet: %+v", other)
53 }
54}