Format entire source code using make fmt
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -7,8 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
func writeTempFile(t *testing.T, input string) (string) {
|
||||
func writeTempFile(t *testing.T, input string) string {
|
||||
tempFile, createTempError := os.CreateTemp("", "syncuids-*")
|
||||
assert.NoError(t, createTempError)
|
||||
_, writeError := tempFile.Write([]byte(input))
|
||||
@@ -17,8 +16,7 @@ func writeTempFile(t *testing.T, input string) (string) {
|
||||
return tempFile.Name()
|
||||
}
|
||||
|
||||
|
||||
func makeSyncDB(t *testing.T, hostInput string, containerInput string) (syncDB) {
|
||||
func makeSyncDB(t *testing.T, hostInput string, containerInput string) syncDB {
|
||||
hostFileName := writeTempFile(t, hostInput)
|
||||
defer os.Remove(hostFileName)
|
||||
containerFileName := writeTempFile(t, containerInput)
|
||||
@@ -32,7 +30,6 @@ func makeSyncDB(t *testing.T, hostInput string, containerInput string) (syncDB)
|
||||
return db
|
||||
}
|
||||
|
||||
|
||||
func Test_readFromHost_single(t *testing.T) {
|
||||
hostFileName := writeTempFile(t, `testuser:x:1001:1001::/home/testuser:/bin/bash`)
|
||||
defer os.Remove(hostFileName)
|
||||
@@ -46,7 +43,6 @@ func Test_readFromHost_single(t *testing.T) {
|
||||
assert.Equal(t, -1, db["testuser"].ContainerID)
|
||||
}
|
||||
|
||||
|
||||
func Test_readFromHost_multiple(t *testing.T) {
|
||||
hostFileName := writeTempFile(t, `
|
||||
testuser1:x:1001:1001::/home/testuser:/bin/bash
|
||||
@@ -65,7 +61,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash
|
||||
assert.Equal(t, -1, db["testuser2"].ContainerID)
|
||||
}
|
||||
|
||||
|
||||
func Test_readFromContainer_single(t *testing.T) {
|
||||
containerFileName := writeTempFile(t, `testuser:x:1001:1001::/home/testuser:/bin/bash`)
|
||||
defer os.Remove(containerFileName)
|
||||
@@ -79,7 +74,6 @@ func Test_readFromContainer_single(t *testing.T) {
|
||||
assert.Equal(t, -1, db["testuser"].HostID)
|
||||
}
|
||||
|
||||
|
||||
func Test_readFromContainer_multiple(t *testing.T) {
|
||||
containerFileName := writeTempFile(t, `
|
||||
testuser1:x:1001:1001::/home/testuser:/bin/bash
|
||||
@@ -97,7 +91,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash
|
||||
assert.Equal(t, -1, db["testuser2"].HostID)
|
||||
}
|
||||
|
||||
|
||||
func Test_readFromBoth_multiple(t *testing.T) {
|
||||
containerFileName := writeTempFile(t, `
|
||||
testuser1:x:1001:1001::/home/testuser:/bin/bash
|
||||
@@ -105,7 +98,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash
|
||||
`)
|
||||
defer os.Remove(containerFileName)
|
||||
|
||||
|
||||
hostFileName := writeTempFile(t, `
|
||||
testuser1:x:2001:2001::/home/testuser:/bin/bash
|
||||
testuser3:x:2003:2003::/home/testuser:/bin/bash
|
||||
@@ -127,19 +119,16 @@ testuser3:x:2003:2003::/home/testuser:/bin/bash
|
||||
assert.Equal(t, 2003, db["testuser3"].HostID)
|
||||
}
|
||||
|
||||
|
||||
func Test_checkConflicts_empty(t *testing.T) {
|
||||
db := makeSyncDB(t, "", "")
|
||||
assert.NoError(t, db.checkConflicts())
|
||||
}
|
||||
|
||||
|
||||
func Test_checkConflicts_single(t *testing.T) {
|
||||
db := makeSyncDB(t, "", "testuser:x:1001:1001::/home/testuser:/bin/bash")
|
||||
assert.NoError(t, db.checkConflicts())
|
||||
}
|
||||
|
||||
|
||||
func Test_checkConflicts_match(t *testing.T) {
|
||||
db := makeSyncDB(t,
|
||||
"testuser:x:1001:1001::/home/testuser:/bin/bash",
|
||||
@@ -147,7 +136,6 @@ func Test_checkConflicts_match(t *testing.T) {
|
||||
assert.NoError(t, db.checkConflicts())
|
||||
}
|
||||
|
||||
|
||||
func Test_checkConflicts_conflict(t *testing.T) {
|
||||
db := makeSyncDB(t,
|
||||
"testuser2:x:1001:1001::/home/testuser:/bin/bash",
|
||||
@@ -155,7 +143,6 @@ func Test_checkConflicts_conflict(t *testing.T) {
|
||||
assert.Error(t, db.checkConflicts())
|
||||
}
|
||||
|
||||
|
||||
func Test_getOnlyContainerLines(t *testing.T) {
|
||||
containerFileName := writeTempFile(t, `
|
||||
testuser1:x:1001:1001::/home/testuser:/bin/bash
|
||||
@@ -163,7 +150,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash
|
||||
`)
|
||||
defer os.Remove(containerFileName)
|
||||
|
||||
|
||||
hostFileName := writeTempFile(t, `
|
||||
testuser1:x:2001:2001::/home/testuser:/bin/bash
|
||||
testuser3:x:2003:2003::/home/testuser:/bin/bash
|
||||
@@ -184,13 +170,11 @@ testuser3:x:2003:2003::/home/testuser:/bin/bash
|
||||
assert.Equal(t, lines[0], "testuser2:x:1002:1002::/home/testuser:/bin/bash")
|
||||
}
|
||||
|
||||
|
||||
func Test_needsSync_empty(t *testing.T) {
|
||||
db := makeSyncDB(t, "", "")
|
||||
assert.False(t, db.needsSync())
|
||||
}
|
||||
|
||||
|
||||
func Test_needsSync_containerOnly(t *testing.T) {
|
||||
db := makeSyncDB(t, "", `
|
||||
testuser1:x:1001:1001::/home/testuser:/bin/bash
|
||||
@@ -199,7 +183,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash`)
|
||||
assert.False(t, db.needsSync())
|
||||
}
|
||||
|
||||
|
||||
func Test_needsSync_hostOnly(t *testing.T) {
|
||||
db := makeSyncDB(t, `
|
||||
testuser1:x:1001:1001::/home/testuser:/bin/bash
|
||||
@@ -208,7 +191,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash`, "")
|
||||
assert.True(t, db.needsSync())
|
||||
}
|
||||
|
||||
|
||||
func Test_needsSync_match(t *testing.T) {
|
||||
db := makeSyncDB(t,
|
||||
"testuser:x:1001:1001::/home/testuser:/bin/bash",
|
||||
@@ -217,7 +199,6 @@ func Test_needsSync_match(t *testing.T) {
|
||||
assert.False(t, db.needsSync())
|
||||
}
|
||||
|
||||
|
||||
func Test_needsSync_differ(t *testing.T) {
|
||||
db := makeSyncDB(t,
|
||||
`
|
||||
@@ -230,7 +211,6 @@ testuser2:x:1002:1002::/home/testuser:/bin/bash`)
|
||||
assert.True(t, db.needsSync())
|
||||
}
|
||||
|
||||
|
||||
func Test_onlyHost(t *testing.T) {
|
||||
db := makeSyncDB(t, "testuser1:x:2001:2001::/home/testuser:/bin/bash", "")
|
||||
entry := db["testuser1"]
|
||||
@@ -242,7 +222,6 @@ func Test_onlyHost(t *testing.T) {
|
||||
assert.False(t, entry.differ())
|
||||
}
|
||||
|
||||
|
||||
func Test_onlyContainer(t *testing.T) {
|
||||
db := makeSyncDB(t, "", "testuser1:x:2001:2001::/home/testuser:/bin/bash")
|
||||
entry := db["testuser1"]
|
||||
@@ -254,7 +233,6 @@ func Test_onlyContainer(t *testing.T) {
|
||||
assert.False(t, entry.differ())
|
||||
}
|
||||
|
||||
|
||||
func Test_match(t *testing.T) {
|
||||
db := makeSyncDB(t,
|
||||
"testuser1:x:2001:2001::/home/testuser:/bin/bash",
|
||||
@@ -268,7 +246,6 @@ func Test_match(t *testing.T) {
|
||||
assert.False(t, entry.differ())
|
||||
}
|
||||
|
||||
|
||||
func Test_differ(t *testing.T) {
|
||||
db := makeSyncDB(t,
|
||||
"testuser1:x:1001:1001::/home/testuser:/bin/bash",
|
||||
|
||||
Reference in New Issue
Block a user