<commit_before>package sdk

import "testing"

func TestInterpolate(t *testing.T) {
	type args struct {
		input string
		vars  map[string]string
	}
	tests := []struct {
		name    string
		args    args
		want    string
		wantErr bool
	}{
		{
			name: "simple",
			args: args{
				input: "a {{.cds.app.value}}",
				vars:  map[string]string{"cds.app.value": "value"},
			},
			want: "a value",
		},
		{
			name: "only unknown",
			args: args{<commit_msg>test (sdk): add benchmark interpolate (#1661)<commit_after>package sdk

import (
	"fmt"
	"testing"
)

func BenchmarkInterpolate(b *testing.B) {
	for n := 0; n < b.N; n++ {

		type args struct {
			input string
			vars  map[string]string
		}
		test := struct {
			name    string
			args    args
			want    string
			wantErr bool
		}{
			name: "config",
			args: args{
				input: `
				{
				"env": {
				"KEYA":"{{.cds.env.vAppKey}}",
				"KEYB": "{{.cds.env.vAppKeyHatchery}}",
				"ADDR":"{{.cds.env.addr}}"
				},
				"labels": {
				"TOKEN": "{{.cds.env.token}}",
				"HOST": "cds-hatchery-marathon-{{.cds.env.name}}.{{.cds.env.vHost}}",
				}
				}`,
				vars: map[string]string{"cds.env.name": "", "cds.env.token": "aValidTokenString", "cds.env.addr": "", "cds.env.vAppKey": "aValue"},
			},
			want: `
				{
				"env": {
				"KEYA":"aValue",
				"KEYB": "{{.cds.env.vAppKeyHatchery}}",
				"ADDR":""
				},
				"labels": {
				"TOKEN": "aValidTokenString",
				"HOST": "cds-hatchery-marathon-.{{.cds.env.vHost}}",
				}
				}`,
		}

		for i := 0; i < 60; i++ {
			test.args.vars[fmt.Sprint("%d", i)] = fmt.Sprintf(">>%d<<", i)
		}

		got, err := Interpolate(test.args.input, test.args.vars)
		if (err != nil) != test.wantErr {
			b.Errorf("Interpolate() error = %v, wantErr %v", err, test.wantErr)
			return
		}
		if got != test.want {
			b.Errorf("Interpolate() = %v, want %v", got, test.want)
		}
	}
}

func TestInterpolate(t *testing.T) {
	type args struct {
		input string
		vars  map[string]string
	}
	tests := []struct {
		name    string
		args    args
		want    string
		wantErr bool
	}{
		{
			name: "simple",
			args: args{
				input: "a {{.cds.app.value}}",
				vars:  map[string]string{"cds.app.value": "value"},
			},
			want: "a value",
		},
		{
			name: "only unknown",
			args: args{
{'fraction_non_alphanumeric': 0.2017738359201774, 'fraction_numerical': 0.003547671840354767, 'mean_word_length': 2.644588045234249, 'pattern_counts': {'":': 20, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4590647', 'n_tokens_mistral': 1093, 'n_tokens_neox': 916, 'n_words': 183}