github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/api_versions_test.go (about)

     1  package e2e
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
     7  	. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
     8  )
     9  
    10  func TestAppSyncWrongVersion(t *testing.T) {
    11  	// Make sure the error messages are good when there are group or version mismatches between CRDs and resources.
    12  	ctx := Given(t)
    13  	ctx.
    14  		Path("crd-version-differences").
    15  		When().
    16  		CreateApp().
    17  		// Install CRD and one instance of it on v1alpha1
    18  		AppSet("--directory-include", "crd-v1alpha1.yaml").
    19  		Sync().
    20  		Then().
    21  		Expect(SyncStatusIs(SyncStatusCodeSynced)).
    22  		When().
    23  		AppSet("--directory-include", "crd-v1alpha2-instance.yaml").
    24  		IgnoreErrors(). // Ignore errors because we are testing the error message.
    25  		Sync().
    26  		Then().
    27  		Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
    28  		When().
    29  		DoNotIgnoreErrors().
    30  		Get().
    31  		Then().
    32  		// Technically it's a "success" because we're just doing a "get," but the get output contains the error message.
    33  		Expect(SuccessRegex(`The Kubernetes API could not find version "v1alpha2" of argoproj\.io/Fake for requested resource [a-z0-9-]+/fake-crd-instance\. Version "v1alpha1" of argoproj\.io/Fake is installed on the destination cluster\.`)).
    34  		When().
    35  		AppSet("--directory-include", "crd-wronggroup-instance.yaml", "--directory-exclude", "crd-v1alpha2-instance.yaml").
    36  		IgnoreErrors(). // Ignore errors because we are testing the error message.
    37  		Sync().
    38  		Then().
    39  		Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
    40  		When().
    41  		DoNotIgnoreErrors().
    42  		Get().
    43  		Then().
    44  		Expect(SuccessRegex(`The Kubernetes API could not find version "v1alpha1" of wrong\.group/Fake for requested resource [a-z0-9-]+/fake-crd-instance-wronggroup\. Version "v1alpha1" of argoproj\.io/Fake is installed on the destination cluster\.`)).
    45  		When().
    46  		AppSet("--directory-include", "crd-does-not-exist-instance.yaml", "--directory-exclude", "crd-wronggroup-instance.yaml").
    47  		IgnoreErrors(). // Ignore errors because we are testing the error message.
    48  		Sync().
    49  		Then().
    50  		Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
    51  		When().
    52  		DoNotIgnoreErrors().
    53  		Get().
    54  		Then().
    55  		// Not the best error message, but good enough.
    56  		Expect(Success(`DoesNotExist.argoproj.io "" not found`))
    57  }