build: fix problems found with ineffasign linter

This commit is contained in:
Nick Craig-Wood 2019-01-11 17:00:59 +00:00
parent 8d5d332daf
commit 97752ca8fb
5 changed files with 21 additions and 9 deletions

View File

@ -392,7 +392,6 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
return nil, errors.New("Container name in SAS URL and container provided in command do not match") return nil, errors.New("Container name in SAS URL and container provided in command do not match")
} }
container = parts.ContainerName
containerURL = azblob.NewContainerURL(*u, pipeline) containerURL = azblob.NewContainerURL(*u, pipeline)
} else { } else {
serviceURL = azblob.NewServiceURL(*u, pipeline) serviceURL = azblob.NewServiceURL(*u, pipeline)

View File

@ -726,6 +726,7 @@ func TestInternalChangeSeenAfterRc(t *testing.T) {
// Call the rc function // Call the rc function
m, err := cacheExpire.Fn(rc.Params{"remote": "data.bin"}) m, err := cacheExpire.Fn(rc.Params{"remote": "data.bin"})
require.NoError(t, err)
require.Contains(t, m, "status") require.Contains(t, m, "status")
require.Contains(t, m, "message") require.Contains(t, m, "message")
require.Equal(t, "ok", m["status"]) require.Equal(t, "ok", m["status"])
@ -735,18 +736,21 @@ func TestInternalChangeSeenAfterRc(t *testing.T) {
co, err = rootFs.NewObject("data.bin") co, err = rootFs.NewObject("data.bin")
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, wrappedTime.Unix(), co.ModTime().Unix()) require.Equal(t, wrappedTime.Unix(), co.ModTime().Unix())
li1, err := runInstance.list(t, rootFs, "") _, err = runInstance.list(t, rootFs, "")
require.NoError(t, err)
// create some rand test data // create some rand test data
testData2 := randStringBytes(int(chunkSize)) testData2 := randStringBytes(int(chunkSize))
runInstance.writeObjectBytes(t, cfs.UnWrap(), runInstance.encryptRemoteIfNeeded(t, "test2"), testData2) runInstance.writeObjectBytes(t, cfs.UnWrap(), runInstance.encryptRemoteIfNeeded(t, "test2"), testData2)
// list should have 1 item only // list should have 1 item only
li1, err = runInstance.list(t, rootFs, "") li1, err := runInstance.list(t, rootFs, "")
require.NoError(t, err)
require.Len(t, li1, 1) require.Len(t, li1, 1)
// Call the rc function // Call the rc function
m, err = cacheExpire.Fn(rc.Params{"remote": "/"}) m, err = cacheExpire.Fn(rc.Params{"remote": "/"})
require.NoError(t, err)
require.Contains(t, m, "status") require.Contains(t, m, "status")
require.Contains(t, m, "message") require.Contains(t, m, "message")
require.Equal(t, "ok", m["status"]) require.Equal(t, "ok", m["status"])
@ -754,6 +758,7 @@ func TestInternalChangeSeenAfterRc(t *testing.T) {
// list should have 2 items now // list should have 2 items now
li2, err := runInstance.list(t, rootFs, "") li2, err := runInstance.list(t, rootFs, "")
require.NoError(t, err)
require.Len(t, li2, 2) require.Len(t, li2, 2)
} }
@ -1490,7 +1495,8 @@ func (r *run) updateData(t *testing.T, rootFs fs.Fs, src, data, append string) e
var err error var err error
if r.useMount { if r.useMount {
f, err := os.OpenFile(path.Join(runInstance.mntDir, src), os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644) var f *os.File
f, err = os.OpenFile(path.Join(runInstance.mntDir, src), os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {
return err return err
} }
@ -1500,7 +1506,8 @@ func (r *run) updateData(t *testing.T, rootFs fs.Fs, src, data, append string) e
}() }()
_, err = f.WriteString(data + append) _, err = f.WriteString(data + append)
} else { } else {
obj1, err := rootFs.NewObject(src) var obj1 fs.Object
obj1, err = rootFs.NewObject(src)
if err != nil { if err != nil {
return err return err
} }

View File

@ -2586,6 +2586,9 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
return err return err
} }
newO, err := o.fs.newObjectWithInfo(src.Remote(), info) newO, err := o.fs.newObjectWithInfo(src.Remote(), info)
if err != nil {
return err
}
switch newO := newO.(type) { switch newO := newO.(type) {
case *Object: case *Object:
*o = *newO *o = *newO
@ -2624,6 +2627,9 @@ func (o *documentObject) Update(in io.Reader, src fs.ObjectInfo, options ...fs.O
remote = remote[:len(remote)-o.extLen] remote = remote[:len(remote)-o.extLen]
newO, err := o.fs.newObjectWithInfo(remote, info) newO, err := o.fs.newObjectWithInfo(remote, info)
if err != nil {
return err
}
switch newO := newO.(type) { switch newO := newO.(type) {
case *documentObject: case *documentObject:
*o = *newO *o = *newO

View File

@ -114,11 +114,11 @@ func TestGetFsAndRemoteNamed(t *testing.T) {
assert.NotNil(t, f) assert.NotNil(t, f)
assert.Equal(t, "hello", remote) assert.Equal(t, "hello", remote)
f, remote, err = GetFsAndRemoteNamed(in, "fsX", "remote") f, _, err = GetFsAndRemoteNamed(in, "fsX", "remote")
require.Error(t, err) require.Error(t, err)
assert.Nil(t, f) assert.Nil(t, f)
f, remote, err = GetFsAndRemoteNamed(in, "fs", "remoteX") f, _, err = GetFsAndRemoteNamed(in, "fs", "remoteX")
require.Error(t, err) require.Error(t, err)
assert.Nil(t, f) assert.Nil(t, f)

View File

@ -74,7 +74,7 @@ func TestOptionsSet(t *testing.T) {
"Int": 50, "Int": 50,
}, },
} }
out, err = call.Fn(in) _, err = call.Fn(in)
require.Error(t, err) require.Error(t, err)
assert.Contains(t, err.Error(), "unknown option block") assert.Contains(t, err.Error(), "unknown option block")
@ -82,7 +82,7 @@ func TestOptionsSet(t *testing.T) {
in = Params{ in = Params{
"potato": []string{"a", "b"}, "potato": []string{"a", "b"},
} }
out, err = call.Fn(in) _, err = call.Fn(in)
require.Error(t, err) require.Error(t, err)
assert.Contains(t, err.Error(), "failed to write options") assert.Contains(t, err.Error(), "failed to write options")
} }