helper_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package client_test
  2. // import (
  3. // "fmt"
  4. // "os"
  5. // "testing"
  6. // "github.com/porter-dev/porter/cli/cmd/docker"
  7. // )
  8. // const baseURL string = "http://localhost:10000/api"
  9. // func TestMain(m *testing.M) {
  10. // err := startPorterServerWithDocker("user", 10000, docker.SQLite)
  11. // if err != nil {
  12. // fmt.Printf("%v\n", err)
  13. // os.Exit(1)
  14. // }
  15. // code := m.Run()
  16. // stopPorterServerWithDocker("user")
  17. // os.Exit(code)
  18. // }
  19. // type db int
  20. // const (
  21. // pg db = iota
  22. // sqlite
  23. // )
  24. // // Spins up and shuts down the Docker api server with the given options
  25. // func startPorterServerWithDocker(processID string, port int, db docker.PorterDB) error {
  26. // env := []string{
  27. // "ADMIN_INIT=false",
  28. // }
  29. // startOpts := &docker.PorterStartOpts{
  30. // ProcessID: processID,
  31. // ServerImageTag: "testing",
  32. // ServerPort: port,
  33. // DB: db,
  34. // Env: env,
  35. // }
  36. // _, _, err := docker.StartPorter(startOpts)
  37. // if err != nil {
  38. // return err
  39. // }
  40. // return nil
  41. // }
  42. // func stopPorterServerWithDocker(processID string) error {
  43. // agent, err := docker.NewAgentFromEnv()
  44. // if err != nil {
  45. // return err
  46. // }
  47. // err = agent.StopPorterContainersWithProcessID(processID, true)
  48. // if err != nil {
  49. // return err
  50. // }
  51. // // remove volumes
  52. // err = agent.RemoveLocalVolume("porter_sqlite_" + processID)
  53. // return nil
  54. // }