Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Jul 1, 2024
1 parent 1bb5641 commit d3790e6
Show file tree
Hide file tree
Showing 2 changed files with 16,839 additions and 0 deletions.
59 changes: 59 additions & 0 deletions pkg/codegen/packagegenerator_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package codegen

import (
"io"
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestReadPackagesFromSource(t *testing.T) {
f, err := os.Open(filepath.Join("testdata", "argocd.yaml"))
require.NoError(t, err)

gen, err := ReadPackagesFromSource("0.0.1", []io.ReadCloser{f})
require.NoError(t, err)

rollout, ok := gen.Types["kubernetes:argoproj.io/v1alpha1:Rollout"]
require.True(t, ok)

// Required inputs

_, ok = rollout.Properties["spec"]
assert.True(t, ok)
assert.Contains(t, rollout.Required, "spec")

_, ok = rollout.Properties["metadata"]
assert.True(t, ok)
assert.Contains(t, rollout.Required, "metadata")

_, ok = rollout.Properties["apiVersion"]
assert.True(t, ok)
assert.Contains(t, rollout.Required, "apiVersion")

_, ok = rollout.Properties["kind"]
assert.True(t, ok)
assert.Contains(t, rollout.Required, "kind")

// The CRD isn't able to communicate that "status" is a required output.
// Verify it's at least not a required input for now. _, ok =
// rollout.Properties["status"]
assert.True(t, ok)
assert.NotContains(t, rollout.Required, "status")
}
Loading

0 comments on commit d3790e6

Please sign in to comment.