MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / TestGetFeature

Function TestGetFeature

backend/pkg/httpserver/get_feature_test.go:32–446  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestGetFeature(t *testing.T) {
33 defaultExpectedBrowsers := []backend.BrowserPathParam{
34 backend.Chrome,
35 backend.Edge,
36 backend.Firefox,
37 backend.Safari,
38 backend.ChromeAndroid,
39 backend.FirefoxAndroid,
40 backend.SafariIos,
41 }
42 testCases := []struct {
43 name string
44 mockConfig *MockGetFeatureByIDConfig
45 expectedCallCount int // For the mock method
46 expectedCacheCalls []*ExpectedCacheCall
47 expectedGetCalls []*ExpectedGetCall
48 request *http.Request
49 expectedResponse *http.Response
50 }{
51 // nolint:dupl // WONTFIX - being explicit for short list of tests.
52 {
53 name: "Success Case - no optional params - use defaults",
54 mockConfig: &MockGetFeatureByIDConfig{
55 expectedFeatureID: "feature1",
56 expectedWPTMetricView: backend.TestCounts,
57 expectedBrowsers: defaultExpectedBrowsers,
58 data: backendtypes.NewGetFeatureResult(backendtypes.NewRegularFeatureResult(&backend.Feature{
59 Baseline: &backend.BaselineInfo{
60 Status: new(backend.Widely),
61 LowDate: new(
62 openapi_types.Date{Time: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)},
63 ),
64 HighDate: new(
65 openapi_types.Date{Time: time.Date(2001, time.January, 1, 0, 0, 0, 0, time.UTC)},
66 ),
67 },
68 DeveloperSignals: nil,
69 BrowserImplementations: &map[string]backend.BrowserImplementation{
70 "chrome": {
71 Status: new(backend.Available),
72 Date: &openapi_types.Date{Time: time.Date(1999, time.January, 1, 0, 0, 0, 0, time.UTC)},
73 Version: new("100"),
74 },
75 },
76 Discouraged: nil,
77 FeatureId: "feature1",
78 Name: "feature 1",
79 Spec: nil,
80 Usage: nil,
81 Wpt: nil,
82 VendorPositions: nil,
83 SystemManagedSavedSearchId: new("saved-search-1"),
84 })),
85 err: nil,
86 },
87 expectedCallCount: 1,
88 request: httptest.NewRequestWithContext(
89 t.Context(),

Callers

nothing calls this directly

Calls 2

getDefaultCacheConfigFunction · 0.85
testJSONResponseFunction · 0.85

Tested by

no test coverage detected