on master help sign in
Merge pull request #619 from obsidiansystems/an@test-private-public-thunk
c969e99Elliot Cameron
all-tests.nix+41−3
@@ -46,6 +46,12 @@ in
46 testScript =
46 testScript =
47 let
47 let
48 privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}'';
48 privateKeyFile = pkgs.writeText "id_rsa" ''${snakeOilPrivateKey}'';
49+ thunkableSample = pkgs.writeText "default.nix" ''
50+ let pkgs = import <nixpkgs> {}; in pkgs.git
51+ '';
52+ invalidThunkableSample = pkgs.writeText "default.nix" ''
53+ let pkgs = import <nixpkgs> {}; in pkgtypo.git
54+ '';
49 sshConfigFile = pkgs.writeText "ssh_config" ''
55 sshConfigFile = pkgs.writeText "ssh_config" ''
50 Host *
56 Host *
51 StrictHostKeyChecking no
57 StrictHostKeyChecking no
@@ -83,7 +89,9 @@ in
83 with subtest("test a git project can be configured with a remote using ssh"):
89 with subtest("test a git project can be configured with a remote using ssh"):
84 client.succeed("mkdir -p ~/code/myapp")
90 client.succeed("mkdir -p ~/code/myapp")
85 client.succeed("cd ~/code/myapp && git init")
91 client.succeed("cd ~/code/myapp && git init")
86− client.succeed("cd ~/code/myapp && touch README")
92+ client.succeed(
93+ "cp ${thunkableSample} ~/code/myapp/default.nix"
94+ )
87 client.succeed("cd ~/code/myapp && git add .")
95 client.succeed("cd ~/code/myapp && git add .")
88 client.succeed('git config --global user.email "you@example.com"')
96 client.succeed('git config --global user.email "you@example.com"')
89 client.succeed('git config --global user.name "Your Name"')
97 client.succeed('git config --global user.name "Your Name"')
@@ -92,16 +100,46 @@ in
92 "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
100 "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
93 )
101 )
94
102
103+
95 with subtest("test pushing code to the remote"):
104 with subtest("test pushing code to the remote"):
96 client.succeed("cd ~/code/myapp && git push -u origin master")
105 client.succeed("cd ~/code/myapp && git push -u origin master")
97 client.succeed("cd ~/code/myapp && git status")
106 client.succeed("cd ~/code/myapp && git status")
98
107
99 with subtest("test obelisk can pack"):
108 with subtest("test obelisk can pack"):
100− client.succeed("ob thunk pack ~/code/myapp")
109+ client.succeed("ob -v thunk pack ~/code/myapp")
101 client.succeed("grep -qF 'git' ~/code/myapp/default.nix")
110 client.succeed("grep -qF 'git' ~/code/myapp/default.nix")
102 client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
111 client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
112+ client.succeed("ob -v thunk unpack ~/code/myapp")
103
113
114+ with subtest("test obelisk can set the public / private flag"):
115+ client.succeed("ob -v thunk pack ~/code/myapp --private")
116+ client.fail("""grep -qF '"private": practice' ~/code/myapp/git.json""")
117+ client.succeed("""grep -qF '"private": true' ~/code/myapp/git.json""")
118+ client.succeed("nix-build ~/code/myapp")
119+ client.succeed("ob -v thunk unpack ~/code/myapp")
120+ client.succeed("ob -v thunk pack ~/code/myapp --public")
121+ client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""")
122+ client.succeed("nix-build ~/code/myapp")
123+ client.succeed("ob -v thunk unpack ~/code/myapp")
124+
125+ with subtest("test building an invalid thunk fails"):
126+ client.succeed("cd ~/code/myapp && git checkout -b bad")
127+ client.succeed(
128+ "cp ${invalidThunkableSample} ~/code/myapp/default.nix"
129+ )
130+ client.succeed("cd ~/code/myapp && git add .")
131+ client.succeed('git config --global user.email "you@example.com"')
132+ client.succeed('git config --global user.name "Your Name"')
133+ client.succeed('cd ~/code/myapp && git commit -m "Bad commit"')
134+ client.succeed("cd ~/code/myapp && git push -u origin bad")
135+ client.succeed("ob -v thunk pack ~/code/myapp --public")
136+ client.fail("nix-build ~/code/myapp")
137+ client.succeed("ob -v thunk unpack ~/code/myapp")
138+ client.succeed("cd ~/code/myapp && git checkout master")
139+
104 with subtest("test obelisk can detect private repos"):
140 with subtest("test obelisk can detect private repos"):
141+ client.succeed("ob -v thunk pack ~/code/myapp")
105 client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""")
142 client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""")
143+ client.succeed("ob -v thunk unpack ~/code/myapp")
106− '';
144+ '';
107 }) {}
145 }) {}