88 "strings"
99 "testing"
1010
11- "github.com/stretchr/testify/assert "
11+ "github.com/stretchr/testify/require "
1212)
1313
1414func TestZipSources (t * testing.T ) {
@@ -73,15 +73,15 @@ func TestZipSources(t *testing.T) {
7373 },
7474 {
7575 name : "empty list" ,
76- setupFunc : func (tempDir string ) ([]string , error ) {
76+ setupFunc : func (_ string ) ([]string , error ) {
7777 return []string {}, nil
7878 },
7979 expectedFiles : map [string ]string {},
8080 expectError : false ,
8181 },
8282 {
8383 name : "non-existent source" ,
84- setupFunc : func (tempDir string ) ([]string , error ) {
84+ setupFunc : func (_ string ) ([]string , error ) {
8585 return []string {"/non/existent/path" }, nil
8686 },
8787 expectedFiles : nil ,
@@ -101,44 +101,44 @@ func TestZipSources(t *testing.T) {
101101 err = zipSources (sources , targetZip )
102102
103103 if tt .expectError {
104- assert .Error (t , err , "zipSources should return error" )
104+ require .Error (t , err , "zipSources should return error" )
105105 return
106106 }
107107
108- assert .NoError (t , err , "zipSources should not return error" )
108+ require .NoError (t , err , "zipSources should not return error" )
109109
110110 zipReader , err := zip .OpenReader (targetZip )
111- assert .NoError (t , err , "should be able to open ZIP file" )
111+ require .NoError (t , err , "should be able to open ZIP file" )
112112 defer zipReader .Close ()
113113
114- assert .Equal (t , len (tt .expectedFiles ), len (zipReader .File ), "ZIP should contain expected number of files" )
114+ require .Equal (t , len (tt .expectedFiles ), len (zipReader .File ), "ZIP should contain expected number of files" )
115115
116116 foundFiles := make (map [string ]string )
117117 for _ , file := range zipReader .File {
118118 foundFiles [file .Name ] = ""
119119 if ! strings .HasSuffix (file .Name , "/" ) {
120120 rc , err := file .Open ()
121- assert .NoError (t , err , "should be able to open file %s in ZIP" , file .Name )
121+ require .NoError (t , err , "should be able to open file %s in ZIP" , file .Name )
122122
123123 content , err := io .ReadAll (rc )
124124 rc .Close ()
125- assert .NoError (t , err , "should be able to read file %s" , file .Name )
125+ require .NoError (t , err , "should be able to read file %s" , file .Name )
126126
127127 foundFiles [file .Name ] = string (content )
128128 }
129129 }
130130
131131 for expectedFile , expectedContent := range tt .expectedFiles {
132132 foundContent , exists := foundFiles [expectedFile ]
133- assert .True (t , exists , "expected file %s should be found in ZIP" , expectedFile )
133+ require .True (t , exists , "expected file %s should be found in ZIP" , expectedFile )
134134 if expectedContent != "" {
135- assert .Equal (t , expectedContent , foundContent , "content should match for file %s" , expectedFile )
135+ require .Equal (t , expectedContent , foundContent , "content should match for file %s" , expectedFile )
136136 }
137137 }
138138
139139 for foundFile := range foundFiles {
140140 _ , expected := tt .expectedFiles [foundFile ]
141- assert .True (t , expected , "unexpected file %s found in ZIP" , foundFile )
141+ require .True (t , expected , "unexpected file %s found in ZIP" , foundFile )
142142 }
143143 })
144144 }
@@ -148,9 +148,9 @@ func TestZipSourcesInvalidTarget(t *testing.T) {
148148 tempDir := t .TempDir ()
149149 testFile := filepath .Join (tempDir , "test.txt" )
150150 err := os .WriteFile (testFile , []byte ("test" ), 0644 )
151- assert .NoError (t , err , "should be able to create test file" )
151+ require .NoError (t , err , "should be able to create test file" )
152152
153153 invalidTarget := "/invalid/path/test.zip"
154154 err = zipSources ([]string {testFile }, invalidTarget )
155- assert .Error (t , err , "zipSources should return error for invalid target" )
155+ require .Error (t , err , "zipSources should return error for invalid target" )
156156}
0 commit comments