Skip to content

Commit

Permalink
test for static archive
Browse files Browse the repository at this point in the history
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
  • Loading branch information
somtochiama committed Jan 25, 2024
1 parent f155227 commit 255f8fc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions oci/client/push_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package client

import (
"bufio"
"bytes"
"context"
"fmt"
"io/fs"
Expand Down Expand Up @@ -299,16 +301,18 @@ func Test_Push_Pull(t *testing.T) {
})
g.Expect(fsErr).ToNot(HaveOccurred())
case LayerTypeStatic:
got, err := os.ReadFile(tmpPath)
g.Expect(err).ToNot(HaveOccurred())

fileInfo, err := os.Stat(tt.sourcePath)
// if a directory was pushed, then the created file is a gzipped archive and
// we don't need to check that its content matches the source directory
// if a directory was pushed, then the created file should be a gzipped archive
if fileInfo.IsDir() {
bufReader := bufio.NewReader(bytes.NewReader(got))
g.Expect(isGzipBlob(bufReader)).To(BeTrue())
return
}
expected, err := os.ReadFile(tt.sourcePath)
g.Expect(err).ToNot(HaveOccurred())

got, err := os.ReadFile(tmpPath)
expected, err := os.ReadFile(tt.sourcePath)
g.Expect(err).ToNot(HaveOccurred())

g.Expect(expected).To(Equal(got))
Expand Down

0 comments on commit 255f8fc

Please sign in to comment.