Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

ci: uci/update-go #51

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"path"
"testing"

"github.com/ipfs/ipfs-ds-convert/testutil"
"os"

"github.com/ipfs/ipfs-ds-convert/testutil"
)

func TestBasicConvert(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions config/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package config

import (
"encoding/json"
"io/ioutil"
"os"
)

func Load(path string, out *map[string]interface{}) error {
cfgbytes, err := ioutil.ReadFile(path)
cfgbytes, err := os.ReadFile(path)
if err != nil {
return err
}
Expand Down
15 changes: 7 additions & 8 deletions convert/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package convert_test

import (
"fmt"
"io/ioutil"
"os"
"path"
"runtime"
Expand All @@ -22,7 +21,7 @@ func TestInvalidRepoVersion(t *testing.T) {
dir, _close, _, _ := testutil.PrepareTest(t, 10, 10)
defer _close(t)

err := ioutil.WriteFile(path.Join(dir, "version"), []byte("147258369"), 0664)
err := os.WriteFile(path.Join(dir, "version"), []byte("147258369"), 0664)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -107,7 +106,7 @@ func TestInvalidVersion(t *testing.T) {
dir, _close, _, _ := testutil.PrepareTest(t, 10, 10)
defer _close(t)

err := ioutil.WriteFile(path.Join(dir, "version"), []byte("a"), 0600)
err := os.WriteFile(path.Join(dir, "version"), []byte("a"), 0600)
if err != nil {
t.Fatal(err)
}
Expand All @@ -128,7 +127,7 @@ func TestInvalidSpecJson(t *testing.T) {
dir, _close, _, _ := testutil.PrepareTest(t, 10, 10)
defer _close(t)

err := ioutil.WriteFile(path.Join(dir, repo.SpecsFile), []byte("}"), 0600)
err := os.WriteFile(path.Join(dir, repo.SpecsFile), []byte("}"), 0600)
if err != nil {
t.Fatal(err)
}
Expand All @@ -149,7 +148,7 @@ func TestInvalidSpecFile(t *testing.T) {
dir, _close, _, _ := testutil.PrepareTest(t, 10, 10)
defer _close(t)

err := ioutil.WriteFile(path.Join(dir, repo.SpecsFile), []byte("{}"), 0600)
err := os.WriteFile(path.Join(dir, repo.SpecsFile), []byte("{}"), 0600)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -191,7 +190,7 @@ func TestInvalidConfigJson(t *testing.T) {
dir, _close, _, _ := testutil.PrepareTest(t, 10, 10)
defer _close(t)

err := ioutil.WriteFile(path.Join(dir, repo.ConfigFile), []byte("}"), 0600)
err := os.WriteFile(path.Join(dir, repo.ConfigFile), []byte("}"), 0600)
if err != nil {
t.Fatal(err)
}
Expand All @@ -212,7 +211,7 @@ func TestInvalidConfigFile(t *testing.T) {
dir, _close, _, _ := testutil.PrepareTest(t, 10, 10)
defer _close(t)

err := ioutil.WriteFile(path.Join(dir, repo.ConfigFile), []byte("{}"), 0600)
err := os.WriteFile(path.Join(dir, repo.ConfigFile), []byte("{}"), 0600)
if err != nil {
t.Fatal(err)
}
Expand All @@ -231,7 +230,7 @@ func TestInvalidConfigFile(t *testing.T) {
t.Fatal(err)
}

err = ioutil.WriteFile(path.Join(dir, repo.ConfigFile), []byte(`{"Datastore":{}}`), 0600)
err = os.WriteFile(path.Join(dir, repo.ConfigFile), []byte(`{"Datastore":{}}`), 0600)
if err != nil {
t.Fatal(err)
}
Expand Down
7 changes: 3 additions & 4 deletions convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package convert

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -135,7 +134,7 @@ func (c *Conversion) saveNewSpec(backup bool) (err error) {
return err
}

err = ioutil.WriteFile(filepath.Join(c.path, repo.SpecsFile), []byte(toDiskId), 0660)
err = os.WriteFile(filepath.Join(c.path, repo.SpecsFile), []byte(toDiskId), 0660)
if err != nil {
return err
}
Expand All @@ -151,12 +150,12 @@ func (c *Conversion) saveNewSpec(backup bool) (err error) {
}

func (c *Conversion) backupSpec() error {
backupFile, err := ioutil.TempFile(c.path, "datastore_spec_backup")
backupFile, err := os.CreateTemp(c.path, "datastore_spec_backup")
if err != nil {
return err
}

specData, err := ioutil.ReadFile(filepath.Join(c.path, repo.SpecsFile))
specData, err := os.ReadFile(filepath.Join(c.path, repo.SpecsFile))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion convert/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestLossyConvert(t *testing.T) {
t.Errorf("expected error 'adding missing to src spec: couldn't find best match for specA /'")
}

//should cover noop case in convert.go
// should cover noop case in convert.go
func TestNoopConvert(t *testing.T) {
//Prepare repo
dir, _close, s1, s2 := testutil.PrepareTest(t, 3000, 3000)
Expand Down
5 changes: 2 additions & 3 deletions convert/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package convert
import (
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -131,7 +130,7 @@ func (c *Copy) openDatastores() (err error) {
}
c.logStep("open datastore at %s", c.path)

c.newDsDir, err = ioutil.TempDir(c.path, "ds-convert")
c.newDsDir, err = os.MkdirTemp(c.path, "ds-convert")
if err != nil {
return errors.Wrapf(err, "error creating temp datastore at %s", c.path)
}
Expand Down Expand Up @@ -231,7 +230,7 @@ func CopyKeys(fromDs repo.Datastore, toDs repo.Datastore) error {
}

func (c *Copy) swapDatastores() (err error) {
c.oldDsDir, err = ioutil.TempDir(c.path, "ds-convert-old")
c.oldDsDir, err = os.MkdirTemp(c.path, "ds-convert-old")
if err != nil {
return errors.Wrapf(err, "error creating temp datastore at %s", c.path)
}
Expand Down
7 changes: 3 additions & 4 deletions convert/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package convert

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -57,7 +56,7 @@ var (
)

func TestInvalidSpecLeft(t *testing.T) {
d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-")
d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-")
if err != nil {
t.Fatalf(err.Error())
}
Expand All @@ -76,7 +75,7 @@ func TestInvalidSpecLeft(t *testing.T) {
}

func TestInvalidSpecRight(t *testing.T) {
d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-")
d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-")
if err != nil {
t.Fatalf(err.Error())
}
Expand All @@ -94,7 +93,7 @@ func TestInvalidSpecRight(t *testing.T) {
}

func TestOpenNonexist(t *testing.T) {
d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-")
d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-")
if err != nil {
t.Fatalf(err.Error())
}
Expand Down
3 changes: 1 addition & 2 deletions convert/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package convert

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand All @@ -15,7 +14,7 @@ import (
)

func (c *Conversion) checkRepoVersion() error {
vstr, err := ioutil.ReadFile(filepath.Join(c.path, "version"))
vstr, err := os.ReadFile(filepath.Join(c.path, "version"))
if err != nil {
return err
}
Expand Down
Loading
Loading