File tree 5 files changed +39
-1
lines changed
5 files changed +39
-1
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2022 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
1
5
package unittest
2
6
3
7
import (
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ func asString(v interface{}) string {
39
39
default :
40
40
panic ("current redis cache doesn't support non-string data type" )
41
41
}
42
- return ""
43
42
}
44
43
45
44
// Put puts value (string type) into cache with key and expire time.
Original file line number Diff line number Diff line change @@ -7,11 +7,38 @@ package util
7
7
import (
8
8
"crypto/aes"
9
9
"crypto/rand"
10
+ "fmt"
11
+ "os"
10
12
"testing"
13
+ "time"
11
14
12
15
"github.com/stretchr/testify/assert"
13
16
)
14
17
18
+ func TestCopyFile (t * testing.T ) {
19
+ testContent := []byte ("hello" )
20
+
21
+ tmpDir := os .TempDir ()
22
+ now := time .Now ()
23
+ srcFile := fmt .Sprintf ("%s/copy-test-%d-src.txt" , tmpDir , now .UnixMicro ())
24
+ dstFile := fmt .Sprintf ("%s/copy-test-%d-dst.txt" , tmpDir , now .UnixMicro ())
25
+
26
+ _ = os .Remove (srcFile )
27
+ _ = os .Remove (dstFile )
28
+ defer func () {
29
+ _ = os .Remove (srcFile )
30
+ _ = os .Remove (dstFile )
31
+ }()
32
+
33
+ err := os .WriteFile (srcFile , testContent , 0o777 )
34
+ assert .NoError (t , err )
35
+ err = CopyFile (srcFile , dstFile )
36
+ assert .NoError (t , err )
37
+ dstContent , err := os .ReadFile (dstFile )
38
+ assert .NoError (t , err )
39
+ assert .Equal (t , testContent , dstContent )
40
+ }
41
+
15
42
func TestAESGCM (t * testing.T ) {
16
43
t .Parallel ()
17
44
Original file line number Diff line number Diff line change
1
+ // Copyright 2022 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
1
5
package util
2
6
3
7
import "github.com/yuin/goldmark/util"
Original file line number Diff line number Diff line change
1
+ // Copyright 2022 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
1
5
package util
2
6
3
7
import (
You can’t perform that action at this time.
0 commit comments