name: "Adds workspace environment variables from plugin when env vars are duplicated"

input:
  devworkspace:
    components:
      - name: test-plugin-a
        plugin:
          uri: "https://my-plugin.io/test-a"
      - name: test-plugin-b
        plugin:
          uri: "https://my-plugin.io/test-b"

  devfileResources:
    "https://my-plugin.io/test-a":
      schemaVersion: 2.0.0
      metadata:
        name: "plugin-a"
      components:
        - name: plugin-a
          attributes:
            workspaceEnv:
              - name: TEST_ENV_1
                value: TEST_VAL_1
              - name: TEST_ENV_2
                value: TEST_VAL_2
          container:
            name: test-container-a
            image: test-image-a
    "https://my-plugin.io/test-b":
      schemaVersion: 2.0.0
      metadata:
        name: "plugin-b"
      components:
        - name: plugin-b
          attributes:
            workspaceEnv:
              - name: TEST_ENV_1
                value: TEST_VAL_1
          container:
            name: test-container-b
            image: test-image-b

output:
  devworkspace:
    components:
      - name: plugin-a
        attributes:
          controller.devfile.io/imported-by: test-plugin-a
          workspaceEnv:
            - name: TEST_ENV_1
              value: TEST_VAL_1
            - name: TEST_ENV_2
              value: TEST_VAL_2
        container:
          name: test-container-a
          image: test-image-a
          env:
          - name: TEST_ENV_1
            value: TEST_VAL_1
          - name: TEST_ENV_2
            value: TEST_VAL_2
      - name: plugin-b
        attributes:
          controller.devfile.io/imported-by: test-plugin-b
          workspaceEnv:
            - name: TEST_ENV_1
              value: TEST_VAL_1
        container:
          name: test-container-b
          image: test-image-b
          env:
          - name: TEST_ENV_1
            value: TEST_VAL_1
          - name: TEST_ENV_2
            value: TEST_VAL_2
