Skip to content

Commit

Permalink
Fix RC conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jmendesky committed Aug 31, 2022
1 parent b38e159 commit 8754717
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 54 deletions.
27 changes: 7 additions & 20 deletions apis/pipelines/v1alpha2/experiment_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,16 @@ import (
)

var _ = Context("Experiment Conversion", func() {
var _ = Describe("ConvertTo", func() {

Specify("Copies all fields", func() {
var _ = Describe("Roundtrip", func() {
Specify("converts to and from the same object", func() {
src := RandomExperiment()
dst := v1alpha3.Experiment{}

Expect(src.ConvertTo(&dst)).To(Succeed())
Expect(dst.ObjectMeta).To(Equal(src.ObjectMeta))
Expect(dst.Spec.Description).To(Equal(src.Spec.Description))
Expect(dst.Status).To(Equal(src.Status))
})
})

var _ = Describe("ConvertFrom", func() {

Specify("Copies all fields", func() {
src := v1alpha3.RandomExperiment()
intermediate := v1alpha3.Experiment{}
dst := Experiment{}

Expect(dst.ConvertFrom(src)).To(Succeed())
Expect(dst.ObjectMeta).To(Equal(src.ObjectMeta))
Expect(dst.Spec.Description).To(Equal(src.Spec.Description))
Expect(dst.Status).To(Equal(src.Status))
Expect(src.ConvertTo(&intermediate)).To(Succeed())
Expect(dst.ConvertFrom(&intermediate)).To(Succeed())

Expect(&dst).To(Equal(src))
})
})

Expand Down
28 changes: 10 additions & 18 deletions apis/pipelines/v1alpha2/pipeline_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ var _ = Context("Pipeline Conversion", func() {
{Name: "c", Value: "d"},
}))
})

Specify("Copies all other fields", func() {
src := RandomPipeline()
dst := v1alpha3.Pipeline{}

Expect(src.ConvertTo(&dst)).To(Succeed())
Expect(dst.Spec.Image).To(Equal(src.Spec.Image))
Expect(dst.Spec.TfxComponents).To(Equal(src.Spec.TfxComponents))
Expect(dst.ObjectMeta).To(Equal(src.ObjectMeta))
Expect(dst.Status).To(Equal(src.Status))
})
})

var _ = Describe("ConvertFrom", func() {
Expand Down Expand Up @@ -89,15 +78,18 @@ var _ = Context("Pipeline Conversion", func() {
Expect(dst.ConvertFrom(&src)).NotTo(Succeed())
})

Specify("Copies all other fields", func() {
src := v1alpha3.RandomPipeline()
})

var _ = Describe("Roundtrip", func() {
Specify("converts to and from the same object", func() {
src := RandomPipeline()
intermediate := v1alpha3.Pipeline{}
dst := Pipeline{}

Expect(dst.ConvertFrom(src)).To(Succeed())
Expect(dst.Spec.Image).To(Equal(src.Spec.Image))
Expect(dst.Spec.TfxComponents).To(Equal(src.Spec.TfxComponents))
Expect(dst.ObjectMeta).To(Equal(src.ObjectMeta))
Expect(dst.Status).To(Equal(src.Status))
Expect(src.ConvertTo(&intermediate)).To(Succeed())
Expect(dst.ConvertFrom(&intermediate)).To(Succeed())

Expect(&dst).To(Equal(src))
})
})

Expand Down
6 changes: 6 additions & 0 deletions apis/pipelines/v1alpha2/runconfiguration_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ func (src *RunConfiguration) ConvertTo(dstRaw conversion.Hub) error {

dst.ObjectMeta = src.ObjectMeta
dst.Spec.RuntimeParameters = mapToNamedValues(src.Spec.RuntimeParameters)
dst.Spec.Pipeline = v1alpha3.PipelineIdentifier{Name: src.Spec.Pipeline.Name, Version: src.Spec.Pipeline.Version}
dst.Spec.Schedule = src.Spec.Schedule
dst.Spec.ExperimentName = src.Spec.ExperimentName
dst.Status = v1alpha3.RunConfigurationStatus(src.Status)

return nil
Expand All @@ -25,6 +28,9 @@ func (dst *RunConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
if err != nil {
return err
}
dst.Spec.Pipeline = PipelineIdentifier{Name: src.Spec.Pipeline.Name, Version: src.Spec.Pipeline.Version}
dst.Spec.Schedule = src.Spec.Schedule
dst.Spec.ExperimentName = src.Spec.ExperimentName
dst.Status = RunConfigurationStatus(src.Status)

return nil
Expand Down
25 changes: 9 additions & 16 deletions apis/pipelines/v1alpha2/runconfiguration_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ var _ = Context("RunConfiguration Conversion", func() {
{Name: "c", Value: "d"},
}))
})

Specify("Copies all other fields", func() {
src := RandomRunConfiguration()
dst := v1alpha3.RunConfiguration{}

Expect(src.ConvertTo(&dst)).To(Succeed())
Expect(dst.ObjectMeta).To(Equal(src.ObjectMeta))
Expect(dst.Status.Status).To(Equal(src.Status.Status))
Expect(dst.Status.ObservedPipelineVersion).To(Equal(src.Status.ObservedPipelineVersion))
})
})

var _ = Describe("ConvertFrom", func() {
Expand All @@ -59,15 +49,18 @@ var _ = Context("RunConfiguration Conversion", func() {

Expect(dst.ConvertFrom(&src)).NotTo(Succeed())
})
})

Specify("Copies all other fields", func() {
src := v1alpha3.RandomRunConfiguration()
var _ = Describe("Roundtrip", func() {
Specify("converts to and from the same object", func() {
src := RandomRunConfiguration()
intermediate := v1alpha3.RunConfiguration{}
dst := RunConfiguration{}

Expect(dst.ConvertFrom(src)).To(Succeed())
Expect(dst.ObjectMeta).To(Equal(src.ObjectMeta))
Expect(dst.Status.Status).To(Equal(src.Status.Status))
Expect(dst.Status.ObservedPipelineVersion).To(Equal(src.Status.ObservedPipelineVersion))
Expect(src.ConvertTo(&intermediate)).To(Succeed())
Expect(dst.ConvertFrom(&intermediate)).To(Succeed())

Expect(&dst).To(Equal(src))
})
})

Expand Down

0 comments on commit 8754717

Please sign in to comment.