docker_cli_plugins_test.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package main
  2. import (
  3. "github.com/docker/docker/pkg/integration/checker"
  4. "github.com/go-check/check"
  5. "strings"
  6. )
  7. var (
  8. pName = "tiborvass/no-remove"
  9. pTag = "latest"
  10. pNameWithTag = pName + ":" + pTag
  11. )
  12. func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
  13. testRequires(c, DaemonIsLinux, ExperimentalDaemon)
  14. _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
  15. c.Assert(err, checker.IsNil)
  16. out, _, err := dockerCmdWithError("plugin", "ls")
  17. c.Assert(err, checker.IsNil)
  18. c.Assert(out, checker.Contains, pName)
  19. c.Assert(out, checker.Contains, pTag)
  20. c.Assert(out, checker.Contains, "true")
  21. out, _, err = dockerCmdWithError("plugin", "inspect", pNameWithTag)
  22. c.Assert(err, checker.IsNil)
  23. c.Assert(out, checker.Contains, "A test plugin for Docker")
  24. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  25. c.Assert(out, checker.Contains, "is active")
  26. _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
  27. c.Assert(err, checker.IsNil)
  28. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  29. c.Assert(err, checker.IsNil)
  30. c.Assert(out, checker.Contains, pNameWithTag)
  31. }
  32. func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
  33. testRequires(c, DaemonIsLinux, ExperimentalDaemon)
  34. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
  35. c.Assert(err, checker.IsNil)
  36. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  37. out, _, err = dockerCmdWithError("plugin", "ls")
  38. c.Assert(err, checker.IsNil)
  39. c.Assert(out, checker.Contains, "false")
  40. out, _, err = dockerCmdWithError("plugin", "enable", pName)
  41. c.Assert(err, checker.IsNil)
  42. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  43. out, _, err = dockerCmdWithError("plugin", "disable", pName)
  44. c.Assert(err, checker.IsNil)
  45. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  46. out, _, err = dockerCmdWithError("plugin", "remove", pName)
  47. c.Assert(err, checker.IsNil)
  48. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  49. }
  50. func (s *DockerSuite) TestPluginInstallImage(c *check.C) {
  51. testRequires(c, DaemonIsLinux, ExperimentalDaemon)
  52. out, _, err := dockerCmdWithError("plugin", "install", "redis")
  53. c.Assert(err, checker.NotNil)
  54. c.Assert(out, checker.Contains, "content is not a plugin")
  55. }
  56. func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {
  57. testRequires(c, DaemonIsLinux, ExperimentalDaemon)
  58. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
  59. c.Assert(err, checker.IsNil)
  60. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  61. out, _, err = dockerCmdWithError("plugin", "enable", pName)
  62. c.Assert(err, checker.NotNil)
  63. c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled")
  64. _, _, err = dockerCmdWithError("plugin", "disable", pName)
  65. c.Assert(err, checker.IsNil)
  66. out, _, err = dockerCmdWithError("plugin", "disable", pName)
  67. c.Assert(err, checker.NotNil)
  68. c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled")
  69. _, _, err = dockerCmdWithError("plugin", "remove", pName)
  70. c.Assert(err, checker.IsNil)
  71. }