@@ -120,6 +120,7 @@ func TestCreateClients(t *testing.T) {
120120 assert .NotNil (t , c .GrafanaAPI )
121121 assert .NotNil (t , c .MLAPI )
122122 assert .NotNil (t , c .SLOClient )
123+ assert .Nil (t , c .OnCallClient )
123124 },
124125 },
125126 {
@@ -133,6 +134,43 @@ func TestCreateClients(t *testing.T) {
133134 assert .NotNil (t , c .GrafanaAPI )
134135 },
135136 },
137+ {
138+ name : "Stack URL and auth to be set, empty strings; OnCall URL set (it has a default)" ,
139+ config : ProviderConfig {
140+ URL : types .StringValue ("" ),
141+ Auth : types .StringValue ("" ),
142+ OncallURL : types .StringValue ("http://oncall.url" ),
143+ },
144+ expected : func (c * common.Client , err error ) {
145+ assert .Nil (t , err )
146+ assert .NotNil (t , c .GrafanaAPI )
147+ },
148+ },
149+ {
150+ name : "OnCall client using original config (not setting Grafana URL)" ,
151+ config : ProviderConfig {
152+ OncallAccessToken : types .StringValue ("oncall-token" ),
153+ OncallURL : types .StringValue ("http://oncall.url" ),
154+ },
155+ expected : func (c * common.Client , err error ) {
156+ assert .Nil (t , err )
157+ assert .NotNil (t , c .OnCallClient )
158+ assert .Nil (t , c .OnCallClient .GrafanaURL ())
159+ },
160+ },
161+ {
162+ name : "OnCall client setting Grafana URL (using Grafana URL and auth)" ,
163+ config : ProviderConfig {
164+ URL : types .StringValue ("http://localhost:3000" ),
165+ Auth : types .StringValue ("service-account-token" ),
166+ OncallURL : types .StringValue ("http://oncall.url" ),
167+ },
168+ expected : func (c * common.Client , err error ) {
169+ assert .Nil (t , err )
170+ assert .NotNil (t , c .OnCallClient )
171+ assert .Equal (t , "http://localhost:3000" , c .OnCallClient .GrafanaURL ().String ())
172+ },
173+ },
136174 }
137175
138176 for _ , tc := range testCases {
0 commit comments