Skip to content

Commit

Permalink
GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Mar 27, 2024
1 parent 2e9f5bb commit 83e5a8e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
29 changes: 29 additions & 0 deletions scripts/github-actions/ga-object-schema-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Copyright 2024 Google LLC
#
# 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.
set -o errexit
set -o nounset
set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
source ${REPO_ROOT}/scripts/shared-vars-public.sh
cd ${REPO_ROOT}
source ${REPO_ROOT}/scripts/fetch_ext_bins.sh && \
fetch_tools && \
setup_envs

cd ${REPO_ROOT}/
echo "Running mock e2e object schema tests..."
E2E_KUBE_TARGET=envtest \
RUN_E2E=1 E2E_GCP_TARGET=mock \
go test -test.count=1 -timeout 3600s -v ./tests/e2e -run TestKubeObject/fixtures 2>&1
14 changes: 10 additions & 4 deletions tests/e2e/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,23 @@ func compareGoldenObject(path string, got []byte) error {
if writeGoldenOutput && os.IsNotExist(err) {
// Expected when creating output for the first time
if err := os.WriteFile(path, got, 0644); err != nil {
return fmt.Errorf("failed to write golden output %s: %v", path, err)
return fmt.Errorf("failed to write golden output %s: %w", path, err)
}
fmt.Printf("wrote updated golden output to %s", path)
return nil
} else {
return fmt.Errorf("failed to read golden file %q: %v", path, err)
return fmt.Errorf("failed to read golden file %q: %w", path, err)
}
}
var wantMap, gotMap map[string]interface{}
yaml.Unmarshal(want, &wantMap)
yaml.Unmarshal(got, &gotMap)
err = yaml.Unmarshal(want, &wantMap)
if err != nil {
return err
}
err = yaml.Unmarshal(got, &gotMap)
if err != nil {
return err
}
if ok, err := compareNestedFields(wantMap, gotMap); !ok {
return err
}
Expand Down

0 comments on commit 83e5a8e

Please sign in to comment.