-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Route browser checks to the browser prober
Make sure that validate works for all check types, and make sure all check types have at least a trivial test. Make sure the probe factory knows how to create checks for all defined types. Follow-up-to: 9730c0b Follow-up-to: db349fd Signed-off-by: Marcelo E. Magallon <[email protected]>
- Loading branch information
Showing
6 changed files
with
237 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package error_types | ||
|
||
// BasicError is an error for which we have no additional information. | ||
type BasicError string | ||
|
||
func (e BasicError) Error() string { return string(e) } | ||
|
||
var _ error = BasicError("") | ||
|
||
// TransientError is an error that can be recovered. | ||
type TransientError BasicError | ||
|
||
func (e TransientError) Error() string { return string(e) } | ||
|
||
var _ error = TransientError("") | ||
|
||
// FatalError is an error that causes the program to terminate. | ||
type FatalError BasicError | ||
|
||
func (e FatalError) Error() string { return string(e) } | ||
|
||
var _ error = FatalError("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
package prober | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/grafana/synthetic-monitoring-agent/internal/model" | ||
sm "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring" | ||
"github.com/rs/zerolog" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestProberFactoryCoverage(t *testing.T) { | ||
// This test will assert that the prober factory is handling all the | ||
// known check types (as defined in the synthetic_monitoring package). | ||
|
||
pf := NewProberFactory(nil, 0) | ||
ctx := context.Background() | ||
testLogger := zerolog.New(zerolog.NewTestWriter(t)) | ||
|
||
for _, checkType := range sm.CheckTypeValues() { | ||
var check model.Check | ||
require.NoError(t, check.FromSM(sm.GetCheckInstance(checkType))) | ||
|
||
_, _, err := pf.New(ctx, testLogger, check) | ||
require.NotErrorIs(t, err, unsupportedCheckType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.