|
4 | 4 | package components_test
|
5 | 5 |
|
6 | 6 | import (
|
7 |
| - "fmt" |
8 | 7 | "testing"
|
9 | 8 |
|
10 |
| - "github.com/go-logr/logr" |
11 | 9 | "github.com/stretchr/testify/assert"
|
12 |
| - corev1 "k8s.io/api/core/v1" |
13 |
| - "k8s.io/apimachinery/pkg/util/intstr" |
14 | 10 |
|
15 | 11 | "github.com/open-telemetry/opentelemetry-operator/internal/components"
|
16 |
| - "github.com/open-telemetry/opentelemetry-operator/internal/components/receivers" |
17 | 12 | )
|
18 | 13 |
|
19 | 14 | func TestComponentType(t *testing.T) {
|
@@ -59,68 +54,3 @@ func TestReceiverParsePortFromEndpoint(t *testing.T) {
|
59 | 54 | })
|
60 | 55 | }
|
61 | 56 | }
|
62 |
| - |
63 |
| -func TestGetPortsForConfig(t *testing.T) { |
64 |
| - type args struct { |
65 |
| - config map[string]interface{} |
66 |
| - retriever components.ParserRetriever |
67 |
| - } |
68 |
| - tests := []struct { |
69 |
| - name string |
70 |
| - args args |
71 |
| - want []corev1.ServicePort |
72 |
| - wantErr assert.ErrorAssertionFunc |
73 |
| - }{ |
74 |
| - { |
75 |
| - name: "nothing", |
76 |
| - args: args{ |
77 |
| - config: nil, |
78 |
| - retriever: receivers.ReceiverFor, |
79 |
| - }, |
80 |
| - want: nil, |
81 |
| - wantErr: assert.NoError, |
82 |
| - }, |
83 |
| - { |
84 |
| - name: "bad config", |
85 |
| - args: args{ |
86 |
| - config: map[string]interface{}{ |
87 |
| - "test": "garbage", |
88 |
| - }, |
89 |
| - retriever: receivers.ReceiverFor, |
90 |
| - }, |
91 |
| - want: nil, |
92 |
| - wantErr: assert.Error, |
93 |
| - }, |
94 |
| - { |
95 |
| - name: "receivers", |
96 |
| - args: args{ |
97 |
| - config: map[string]interface{}{ |
98 |
| - "otlp": map[string]interface{}{ |
99 |
| - "protocols": map[string]interface{}{ |
100 |
| - "grpc": map[string]interface{}{}, |
101 |
| - }, |
102 |
| - }, |
103 |
| - }, |
104 |
| - retriever: receivers.ReceiverFor, |
105 |
| - }, |
106 |
| - want: []corev1.ServicePort{ |
107 |
| - { |
108 |
| - Name: "otlp-grpc", |
109 |
| - Port: 4317, |
110 |
| - TargetPort: intstr.FromInt32(4317), |
111 |
| - AppProtocol: &components.GrpcProtocol, |
112 |
| - }, |
113 |
| - }, |
114 |
| - wantErr: assert.NoError, |
115 |
| - }, |
116 |
| - } |
117 |
| - for _, tt := range tests { |
118 |
| - t.Run(tt.name, func(t *testing.T) { |
119 |
| - got, err := components.GetPortsForConfig(logr.Discard(), tt.args.config, tt.args.retriever) |
120 |
| - if !tt.wantErr(t, err, fmt.Sprintf("GetPortsForConfig(%v)", tt.args.config)) { |
121 |
| - return |
122 |
| - } |
123 |
| - assert.Equalf(t, tt.want, got, "GetPortsForConfig(%v)", tt.args.config) |
124 |
| - }) |
125 |
| - } |
126 |
| -} |
0 commit comments