File: utils_test.go

package info (click to toggle)
prometheus-mongodb-exporter 1.0.0%2Bgit20180522.e755a44-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 668 kB
  • sloc: sh: 65; makefile: 27
file content (41 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package shared

import (
	"testing"
)

func Test_SnakeCase(t *testing.T) {
	cases := []struct {
		in  string
		out string
	}{
		{in: "testing-string", out: "testing_string"},
		{in: "TestingString", out: "testing_string"},
		{in: "Testing_String", out: "testing__string"},
		{in: "", out: ""},
	}

	for _, test := range cases {
		if out := SnakeCase(test.in); out != test.out {
			t.Errorf("expected %s but got %s", test.out, out)
		}
	}
}

func Test_ParameterizeString(t *testing.T) {
	cases := []struct {
		in  string
		out string
	}{
		{in: "testing-string", out: "testing_string"},
		{in: "TestingString", out: "testingstring"},
		{in: "Testing-String", out: "testing_string"},
		{in: "", out: ""},
	}

	for _, test := range cases {
		if out := ParameterizeString(test.in); out != test.out {
			t.Errorf("expected %s but got %s", test.out, out)
		}
	}
}