on master help sign in
Merge pull request #619 from obsidiansystems/an@test-private-public-thunk

Test public / private flags can be set declaratively

commitc969e995e15d1ed647d3046441e2502380217e7d authorElliot Cameron <3noch@users.noreply.github.com> dateTue 14 Jan 2020, 14:46 (7 years ago) parente7677363d2f0e6
1 file changed+41−3
all-tests.nix+41−3
all-tests.nix+41−3
@@ -46,6 +46,12 @@ in
4646 testScript =
4747 let
4848 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+ '';
4955 sshConfigFile = pkgs.writeText "ssh_config" ''
5056 Host *
5157 StrictHostKeyChecking no
@@ -83,7 +89,9 @@ in
8389 with subtest("test a git project can be configured with a remote using ssh"):
8490 client.succeed("mkdir -p ~/code/myapp")
8591 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+ )
8795 client.succeed("cd ~/code/myapp && git add .")
8896 client.succeed('git config --global user.email "you@example.com"')
8997 client.succeed('git config --global user.name "Your Name"')
@@ -92,16 +100,46 @@ in
92100 "cd ~/code/myapp && git remote add origin root@githost:/root/myorg/myapp.git"
93101 )
94102
103+
95104 with subtest("test pushing code to the remote"):
96105 client.succeed("cd ~/code/myapp && git push -u origin master")
97106 client.succeed("cd ~/code/myapp && git status")
98107
99108 with subtest("test obelisk can pack"):
100− client.succeed("ob thunk pack ~/code/myapp")
109+ client.succeed("ob -v thunk pack ~/code/myapp")
101110 client.succeed("grep -qF 'git' ~/code/myapp/default.nix")
102111 client.succeed("grep -qF 'myorg' ~/code/myapp/git.json")
112+ client.succeed("ob -v thunk unpack ~/code/myapp")
103113
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+
104140 with subtest("test obelisk can detect private repos"):
141+ client.succeed("ob -v thunk pack ~/code/myapp")
105142 client.succeed("""grep -qF '"private": false' ~/code/myapp/git.json""")
106− '';
143+ client.succeed("ob -v thunk unpack ~/code/myapp")
144+ '';
107145 }) {}