/tests/rkt_cat_manifest_test.go

https://gitlab.com/github-cloud-corporation/rkt · Go · 70 lines · 42 code · 12 blank · 16 comment · 4 complexity · c63eb1795472d41553eb09023b19f6d2 MD5 · raw file

  1. // Copyright 2015 The rkt Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // +build host coreos src kvm
  15. package main
  16. import (
  17. "fmt"
  18. "os"
  19. "testing"
  20. "github.com/coreos/rkt/tests/testutils"
  21. )
  22. // TestCatManifest tests 'rkt cat-manifest', it will:
  23. func TestCatManifest(t *testing.T) {
  24. const imgName = "rkt-cat-manifest-test"
  25. image := patchTestACI(fmt.Sprintf("%s.aci", imgName), fmt.Sprintf("--name=%s", imgName))
  26. defer os.Remove(image)
  27. imageHash := getHashOrPanic(image)
  28. imgID := ImageID{path: image, hash: imageHash}
  29. ctx := testutils.NewRktRunCtx()
  30. defer ctx.Cleanup()
  31. // Prepare image
  32. cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imgID.path)
  33. podUuid := runRktAndGetUUID(t, cmd)
  34. tmpDir := createTempDirOrPanic(imgName)
  35. defer os.RemoveAll(tmpDir)
  36. tests := []struct {
  37. uuid string
  38. match string
  39. }{
  40. {
  41. podUuid,
  42. imgName,
  43. },
  44. {
  45. podUuid,
  46. imageHash[:20],
  47. },
  48. {
  49. "1234567890abcdef",
  50. "no matches found for",
  51. },
  52. }
  53. for i, tt := range tests {
  54. runCmd := fmt.Sprintf("%s cat-manifest --pretty-print=false %s", ctx.Cmd(), tt.uuid)
  55. t.Logf("Running test #%d", i)
  56. runRktAndCheckRegexOutput(t, runCmd, tt.match)
  57. }
  58. }