oem_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2015 CoreOS, Inc.
  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. package system
  15. import (
  16. "reflect"
  17. "testing"
  18. "github.com/rancher/os/config/cloudinit/config"
  19. )
  20. func TestOEMFile(t *testing.T) {
  21. for _, tt := range []struct {
  22. config config.OEM
  23. file *File
  24. }{
  25. {
  26. config.OEM{},
  27. nil,
  28. },
  29. {
  30. config.OEM{
  31. ID: "rackspace",
  32. Name: "Rackspace Cloud Servers",
  33. VersionID: "168.0.0",
  34. HomeURL: "https://www.rackspace.com/cloud/servers/",
  35. BugReportURL: "https://github.com/coreos/coreos-overlay",
  36. },
  37. &File{config.File{
  38. Path: "etc/oem-release",
  39. RawFilePermissions: "0644",
  40. Content: `ID=rackspace
  41. VERSION_ID=168.0.0
  42. NAME="Rackspace Cloud Servers"
  43. HOME_URL="https://www.rackspace.com/cloud/servers/"
  44. BUG_REPORT_URL="https://github.com/coreos/coreos-overlay"
  45. `,
  46. }},
  47. },
  48. } {
  49. file, err := OEM{tt.config}.File()
  50. if err != nil {
  51. t.Errorf("bad error (%q): want %v, got %q", tt.config, nil, err)
  52. }
  53. if !reflect.DeepEqual(tt.file, file) {
  54. t.Errorf("bad file (%q): want %#v, got %#v", tt.config, tt.file, file)
  55. }
  56. }
  57. }