MCPcopy Index your code
hub / github.com/devspace-sh/devspace / TestHashDirectory

Function TestHashDirectory

pkg/util/hash/hash_test.go:25–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestHashDirectory(t *testing.T) {
26 dir := t.TempDir()
27
28 wdBackup, err := os.Getwd()
29 if err != nil {
30 t.Fatalf("Error getting current working directory: %v", err)
31 }
32 err = os.Chdir(dir)
33 if err != nil {
34 t.Fatalf("Error changing working directory: %v", err)
35 }
36
37 // 8. Delete temp folder
38 defer func() {
39 err = os.Chdir(wdBackup)
40 if err != nil {
41 t.Fatalf("Error changing dir back: %v", err)
42 }
43 }()
44
45 //Use on empty dir
46 _, err = Directory(".")
47 if err != nil {
48 t.Fatalf("Error creating hash of directory: %v", err)
49 }
50
51 //Use on file
52 _ = fsutil.WriteToFile([]byte(""), "someFile")
53 _, err = Directory("someFile")
54 if err != nil {
55 t.Fatalf("Error creating hash of file: %v", err)
56 }
57
58}
59
60func TestHashDirectoryExcludes(t *testing.T) {
61 dir := t.TempDir()

Callers

nothing calls this directly

Calls 3

WriteToFileFunction · 0.92
DirectoryFunction · 0.85
FatalfMethod · 0.45

Tested by

no test coverage detected