Skip to content

Commit

Permalink
run as current user
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Dec 15, 2023
1 parent d816084 commit 686e55f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions integration/database/rqlite_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"database/sql"
_ "embed"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"os/user"
"path"
"testing"

Expand Down Expand Up @@ -63,9 +64,12 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) {
}

// start rqlite db
rqliteAuthConfigPath := path.Join(t.TempDir(), "rqlite-auth-config.json")
err = ioutil.WriteFile(rqliteAuthConfigPath, []byte(RQLITE_AUTH_CONFIG), 0644)
currentUser, err := user.Current()
if err != nil {
log.Fatalf("Failed to get current user: %s", err)
}
rqliteAuthConfigPath := path.Join(t.TempDir(), "rqlite-auth-config.json")
if err := os.WriteFile(rqliteAuthConfigPath, []byte(RQLITE_AUTH_CONFIG), 0644); err != nil {
t.Fatalf("Failed to write to file %s", rqliteAuthConfigPath)
}
rqliteTag, _ := image.GetTag(image.Rqlite)
Expand All @@ -74,6 +78,7 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) {
Repository: "kotsadm/rqlite",
Tag: rqliteTag,
Mounts: []string{
fmt.Sprintf("%s:/rqlite/file", t.TempDir()),
fmt.Sprintf("%s:/auth/config.json", rqliteAuthConfigPath),
},
ExposedPorts: []string{
Expand All @@ -92,6 +97,7 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) {
"-http-adv-addr=localhost:14001",
"-auth=/auth/config.json",
},
User: currentUser.Uid,
}
rqliteHostConfig := func(config *docker.HostConfig) {
config.AutoRemove = true
Expand Down

0 comments on commit 686e55f

Please sign in to comment.