Skip to content

Commit

Permalink
Merge pull request #89 from caarlos0/ioutil
Browse files Browse the repository at this point in the history
fix: ioutil and other lint issues
  • Loading branch information
jarondl authored Feb 15, 2024
2 parents 7735c14 + 1d4ccd5 commit f0fcb4f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
8 changes: 2 additions & 6 deletions file_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import (
)

func TestFileTypeSetting(t *testing.T) {
f := &RPMFile{
Name: "Test",
}
f := &RPMFile{}

if f.Type != GenericFile {
t.Error("New RPMFile.Type should be a generic type")
Expand All @@ -20,9 +18,7 @@ func TestFileTypeSetting(t *testing.T) {
}

func TestFileTypeCombining(t *testing.T) {
f := &RPMFile{
Name: "Test",
}
f := &RPMFile{}

f.Type |= ConfigFile | NoReplaceFile

Expand Down
7 changes: 3 additions & 4 deletions rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rpmpack

import (
"io"
"io/ioutil"
"reflect"
"testing"

Expand All @@ -29,7 +28,7 @@ func TestFileOwner(t *testing.T) {
Owner: user,
})

if err := r.Write(ioutil.Discard); err != nil {
if err := r.Write(io.Discard); err != nil {
t.Errorf("NewRPM returned error %v", err)
}
if r.fileowners[0] != user {
Expand All @@ -52,7 +51,7 @@ func Test100644(t *testing.T) {
Mode: 0100644,
})

if err := r.Write(ioutil.Discard); err != nil {
if err := r.Write(io.Discard); err != nil {
t.Errorf("Write returned error %v", err)
}
if r.filemodes[0] != 0100644 {
Expand Down Expand Up @@ -173,7 +172,7 @@ func TestAllowListDirs(t *testing.T) {

r.AllowListDirs(map[string]bool{"/usr/local/dir1": true})

if err := r.Write(ioutil.Discard); err != nil {
if err := r.Write(io.Discard); err != nil {
t.Errorf("NewRPM returned error %v", err)
}
expected := map[string]RPMFile{"/usr/local/dir1": {Name: "/usr/local/dir1", Mode: 040000}}
Expand Down
4 changes: 1 addition & 3 deletions tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ import (
"archive/tar"
"fmt"
"io"
"io/ioutil"
"path"
)

// FromTar reads a tar file and creates an rpm stuct.
func FromTar(inp io.Reader, md RPMMetaData) (*RPM, error) {

r, err := NewRPM(md)
if err != nil {
return nil, fmt.Errorf("failed to create RPM structure: %w", err)
Expand All @@ -45,7 +43,7 @@ func FromTar(inp io.Reader, md RPMMetaData) (*RPM, error) {
body = []byte(h.Linkname)
h.Mode |= 0120000
case tar.TypeReg:
b, err := ioutil.ReadAll(t)
b, err := io.ReadAll(t)
if err != nil {
return nil, fmt.Errorf("failed to read file (%q): %w", h.Name, err)
}
Expand Down
4 changes: 1 addition & 3 deletions tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"archive/tar"
"bytes"
"io"
"io/ioutil"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -67,7 +66,6 @@ func createTar(t *testing.T) io.Reader {
}

func TestFromTar(t *testing.T) {

testCases := []struct {
name string
input io.Reader
Expand All @@ -86,7 +84,7 @@ func TestFromTar(t *testing.T) {
if err != nil {
t.Errorf("FromTar returned err: %v", err)
}
if err := r.Write(ioutil.Discard); err != nil {
if err := r.Write(io.Discard); err != nil {
t.Errorf("r.Write() returned err: %v", err)
}
if r == nil {
Expand Down

0 comments on commit f0fcb4f

Please sign in to comment.