MCPcopy
hub / github.com/keploy/keploy / filterByMapping

Function filterByMapping

pkg/util.go:3552–3579  ·  view source on GitHub ↗
(_ context.Context, logger *zap.Logger, m []*models.Mock, mocksPresentInMapping []string)

Source from the content-addressed store, hash-verified

3550}
3551
3552func filterByMapping(_ context.Context, logger *zap.Logger, m []*models.Mock, mocksPresentInMapping []string) ([]*models.Mock, []*models.Mock) {
3553 mapping := make(map[string]bool, len(mocksPresentInMapping))
3554 for _, name := range mocksPresentInMapping {
3555 mapping[name] = true
3556 }
3557 var filtered, unfiltered []*models.Mock
3558 isNonKeploy := false
3559 for _, mock := range m {
3560 if mock == nil {
3561 continue
3562 }
3563 p := mock.DeepCopy()
3564 if p.Version != "api.keploy.io/v1beta1" && p.Version != "api.keploy.io/v1beta2" {
3565 isNonKeploy = true
3566 }
3567 if mapping[p.Name] {
3568 p.TestModeInfo.IsFiltered = true
3569 filtered = append(filtered, p)
3570 } else {
3571 p.TestModeInfo.IsFiltered = false
3572 unfiltered = append(unfiltered, p)
3573 }
3574 }
3575 if isNonKeploy {
3576 logger.Debug("Few mocks in the mock File are not recorded by keploy ignoring them")
3577 }
3578 return filtered, unfiltered
3579}
3580
3581func GuessContentType(data []byte) models.BodyType {
3582 // Use net/http library's DetectContentType for basic MIME type detection

Callers 2

FilterTcsMocksMappingFunction · 0.85
FilterConfigMocksMappingFunction · 0.85

Calls 2

DeepCopyMethod · 0.80
DebugMethod · 0.65

Tested by

no test coverage detected