(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestInputRCAndPod(t *testing.T) { |
| 43 | input := testTempFileInput(t) |
| 44 | defer os.RemoveAll(input.Path()) |
| 45 | |
| 46 | // setup pod |
| 47 | kubePod := testKubePod() |
| 48 | |
| 49 | podFile := fmt.Sprintf("test.%s.%s", PodExtension, testRandomExtension()) |
| 50 | podPath := path.Join(input.Path(), podFile) |
| 51 | testWriteYAMLToFile(t, podPath, kubePod) |
| 52 | testClearTypeInfo(kubePod) |
| 53 | pod, err := entity.NewPod(kubePod, kube.ObjectMeta{}, podPath) |
| 54 | assert.NoError(t, err) |
| 55 | |
| 56 | // setup rc |
| 57 | objects := testWriteRandomObjects(t, input.Path(), 5) |
| 58 | kubeRC := &kube.ReplicationController{ |
| 59 | ObjectMeta: kube.ObjectMeta{ |
| 60 | Name: "spread", |
| 61 | Namespace: kube.NamespaceDefault, |
| 62 | }, |
| 63 | TypeMeta: unversioned.TypeMeta{ |
| 64 | Kind: "ReplicationController", |
| 65 | APIVersion: "v1", |
| 66 | }, |
| 67 | Spec: kube.ReplicationControllerSpec{ |
| 68 | Selector: map[string]string{"valid": "selector"}, |
| 69 | Template: &kube.PodTemplateSpec{ |
| 70 | Spec: kubePod.Spec, |
| 71 | }, |
| 72 | }, |
| 73 | } |
| 74 | |
| 75 | rcFile := fmt.Sprintf("test.%s.%s", RCExtension, testRandomExtension()) |
| 76 | rcPath := path.Join(input.Path(), rcFile) |
| 77 | testWriteYAMLToFile(t, rcPath, kubeRC) |
| 78 | testClearTypeInfo(kubeRC) |
| 79 | rc, err := entity.NewReplicationController(kubeRC, kube.ObjectMeta{}, rcPath) |
| 80 | assert.NoError(t, err) |
| 81 | |
| 82 | expected, err := entity.NewApp(nil, kube.ObjectMeta{}, input.Path(), objects...) |
| 83 | assert.NoError(t, err) |
| 84 | |
| 85 | // attach rc and pod |
| 86 | err = expected.Attach(rc) |
| 87 | assert.NoError(t, err) |
| 88 | err = expected.Attach(pod) |
| 89 | assert.NoError(t, err) |
| 90 | |
| 91 | // generate entity |
| 92 | actual, err := input.Build() |
| 93 | assert.NoError(t, err, "should have built entity successfully") |
| 94 | |
| 95 | testCompareEntity(t, expected, actual) |
| 96 | } |
| 97 | |
| 98 | func testTempFileInput(t *testing.T) *FileInput { |
| 99 | dir := testTempDir(t) |
nothing calls this directly
no test coverage detected