testsing

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareVersions added in v0.12.0

func CompareVersions(version1, version2 string) int

CompareVersions compares two versions in the format "X.Y.Z" and returns: -1 if version1 is less than version2 0 if version1 is equal to version2 1 if version1 is greater than version2

func GetStringFromTemplateWithData

func GetStringFromTemplateWithData(templateName string, templateStr string, templateData TemplateData) string

GetStringFromTemplateWithData returns a string from a template with data.

Here is the example usage: templateStr := GetStringFromTemplateWithData(

"testAccResourceApplicationWithRevisionAndConfig",
`

resource "juju_model" "this" {
 name = "{{.ModelName}}"
}

resource "juju_application" "{{.AppName}}" {
 name  = "{{.AppName}}"
 model = juju_model.this.name

 charm {
   name     = "{{.AppName}}"
   revision = {{.Revision}}
   channel  = "latest/edge"
 }

 {{ if ne .ConfigParamName "" }}
 config = {
   {{.ConfigParamName}} = "{{.ConfigParamName}}-value"
 }
 {{ end }}

 units = 1
}

`, utils.TemplateData{
				"ModelName":       "test-model",
				"AppName":         "test-app"
				"Revision":        fmt.Sprintf("%d", 7),
				"ConfigParamName": "test-config-param-name",
			})

The templateStr will be:

resource "juju_model" "this" {
  name = "test-model"
}

resource "juju_application" "test-app" {
  name  = "test-app"
  model = juju_model.this.name

  charm {
    name     = "test-app"
    revision = 7
    channel  = "latest/edge"
  }

  config = {
    test-config-param-name = "test-config-param-name-value"
  }

  units = 1
}

Types

type TemplateData

type TemplateData map[string]any

TemplateData is a map of string to any that is used to pass data to a template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL