1 // Copyright (C) 2019 Simon Ruderich
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Affero General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Affero General Public License for more details.
13 // You should have received a copy of the GNU Affero General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
25 func TestDeployFile(t *testing.T) {
26 const deploy = "testdata/deploy"
28 // Suppress log messages
29 log.SetOutput(ioutil.Discard)
30 defer log.SetOutput(os.Stderr)
33 f, err := os.Create(deploy)
41 defer os.Remove(deploy)
73 for n, tc := range tests {
74 err = os.Chmod(deploy, tc.perm)
78 err = deployFile(&File{
80 Url: "http://example.org",
82 body: []byte("Hello World!"),
88 info, err := os.Stat(deploy)
92 perm := info.Mode().Perm()
94 t.Errorf("%d: perm = %v, want %v",