fleet_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 TestFleetUnits(t *testing.T) {
  21. for _, tt := range []struct {
  22. config config.Fleet
  23. units []Unit
  24. }{
  25. {
  26. config.Fleet{},
  27. []Unit{{config.Unit{
  28. Name: "fleet.service",
  29. Runtime: true,
  30. DropIns: []config.UnitDropIn{{Name: "20-cloudinit.conf"}},
  31. }}},
  32. },
  33. {
  34. config.Fleet{
  35. PublicIP: "12.34.56.78",
  36. },
  37. []Unit{{config.Unit{
  38. Name: "fleet.service",
  39. Runtime: true,
  40. DropIns: []config.UnitDropIn{{
  41. Name: "20-cloudinit.conf",
  42. Content: `[Service]
  43. Environment="FLEET_PUBLIC_IP=12.34.56.78"
  44. `,
  45. }},
  46. }}},
  47. },
  48. } {
  49. units := Fleet{tt.config}.Units()
  50. if !reflect.DeepEqual(units, tt.units) {
  51. t.Errorf("bad units (%+v): want %#v, got %#v", tt.config, tt.units, units)
  52. }
  53. }
  54. }