Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ioutil and other lint issues #89

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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