Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We need a testing framework for transformers #16

Closed
kajogo777 opened this issue Dec 11, 2022 · 1 comment
Closed

We need a testing framework for transformers #16

kajogo777 opened this issue Dec 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@kajogo777
Copy link
Member

kajogo777 commented Dec 11, 2022

Proposal

Test case schema

#TestCase: {
	name:        string
	description: string

	transformer: #Transformer
	input:       #Component
	result:      input & transformer

	expect: result
	assert: [string]: true
}

Example test case

package main

import (
	"guku.io/devx/v1"
	"guku.io/devx/v1/traits"
	"guku.io/devx/v1/transformers/compose"
)

_t1: v1.#TestCase & {
	name:        "exposable"
	description: ""

	transformer: compose.#ExposeComposeService
	input: {
		traits.#Exposable
		$metadata: id: "obi"
		endpoints: default: ports: [
			{
				port:   8080
				target: 80
			},
		]
	}
	result: _

	expect: {
		endpoints: default: host: "obi"
		$resources: compose: services: obi: ports: ["8080:80"]
	}
	assert: {
		"host is concrete": (result.endpoints.default.host & "123") == _|_
	}
}

Run test

cue eval
@kajogo777 kajogo777 added the enhancement New feature or request label Dec 11, 2022
@kajogo777
Copy link
Member Author

added simple test case schema for transformers in 326f0fe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant