konveyor / move2kube

Move2Kube is a command-line tool for automating creation of Infrastructure as code (IaC) artifacts. It has inbuilt support for creating IaC artifacts for replatforming to Kubernetes/Openshift.
https://move2kube.konveyor.io/
Apache License 2.0
383 stars 118 forks source link

Test to check if all cluster names are properly parsed in generated constants #74

Closed HarikrishnanBalagopal closed 3 years ago

HarikrishnanBalagopal commented 4 years ago

Description

Write unit tests to check the generated files are valid.

Add the below test just before https://github.com/konveyor/move2kube/blob/8c23e21d0f57928d6af63d5f06015a5981aea5e6/internal/metadata/clustermdloader_test.go#L52

    t.Run("check if all clusters in constant were loaded", func(t *testing.T) {
        p := plantypes.NewPlan()
        loader := metadata.ClusterMDLoader{}
        cmMap := loader.GetClusters(p)
                //TODO: Read all .yaml files in internal/metadata/clusters, and find the value in metadata.name using say a regex
        for clustername := range <ALL NAMES IDENTIFIED IN ABOVE STEP> {
            if _, ok := cmMap[clustername]; !ok {
                t.Fatal("Missing builtin "+clustername+" cluster metadata. The returned cluster info:", cmMap)
            }
        }
    })
ashokponkumar commented 4 years ago

@pabloloyola Please take a look into this issue.