From f7fa84bab63063590febb1169f66af1667f5f072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Rzepecki?= Date: Thu, 10 Aug 2023 15:58:32 +0200 Subject: [PATCH] feat: Add recorder type to appmap metadata Fixes #235 --- components/trace/appmap/index.test.mjs | 2 +- components/trace/appmap/metadata.mjs | 11 ++++++++++- components/trace/appmap/metadata.test.mjs | 4 ++-- schema/definitions/recorder.yaml | 1 + test/cases/mocha/mocha/suite-1.subset.yaml | 5 ++++- test/cases/mocha/mocha/suite-2.subset.yaml | 5 ++++- test/cases/mocha/mocha/suite.subset.yaml | 5 ++++- 7 files changed, 26 insertions(+), 7 deletions(-) diff --git a/components/trace/appmap/index.test.mjs b/components/trace/appmap/index.test.mjs index d3e428dcc..fdf85b2aa 100644 --- a/components/trace/appmap/index.test.mjs +++ b/components/trace/appmap/index.test.mjs @@ -173,7 +173,7 @@ assertDeepEqual( url: "https://github.com/applandinc/appmap-agent-js", version: "1.2.3", }, - recorder: { name: "process" }, + recorder: { name: "process", type: "process" }, recording: undefined, git: undefined, test_status: undefined, diff --git a/components/trace/appmap/metadata.mjs b/components/trace/appmap/metadata.mjs index e8fc153f6..8c43de369 100644 --- a/components/trace/appmap/metadata.mjs +++ b/components/trace/appmap/metadata.mjs @@ -76,13 +76,22 @@ const makeTestStatus = (termination) => { } }; +// NOTE: this relies on the fact that schema/definitions/recorder.yaml is an enum +const RECORDER_TYPES = { + process: "process", + mocha: "tests", + jest: "tests", + manual: "process", + remote: "remote", +}; + const makeRecorder = (recorder) => { assert( recorder !== null, "recorder should have been resolved earlier", InternalAppmapError, ); - return { name: recorder }; + return { name: recorder, type: RECORDER_TYPES[recorder] }; }; const makeException = (serials) => { diff --git a/components/trace/appmap/metadata.test.mjs b/components/trace/appmap/metadata.test.mjs index 85b187328..13c7a508b 100644 --- a/components/trace/appmap/metadata.test.mjs +++ b/components/trace/appmap/metadata.test.mjs @@ -39,7 +39,7 @@ const default_meta_data = { version: "1.2.3", url: "http://host/homepage", }, - recorder: { name: "process" }, + recorder: { name: "process", type: "process" }, recording: undefined, git: undefined, test_status: undefined, @@ -67,7 +67,7 @@ assertEqual( // recorder // assertDeepEqual(test({ recorder: "process" }, "protocol://host/base/"), { ...default_meta_data, - recorder: { name: "process" }, + recorder: { name: "process", type: "process" }, }); // exception // diff --git a/schema/definitions/recorder.yaml b/schema/definitions/recorder.yaml index 3e8145729..98bf76392 100644 --- a/schema/definitions/recorder.yaml +++ b/schema/definitions/recorder.yaml @@ -1,3 +1,4 @@ +# NOTE: when changing this, make sure to adjust the type map in components/trace/appmap/metadata enum: - process - mocha diff --git a/test/cases/mocha/mocha/suite-1.subset.yaml b/test/cases/mocha/mocha/suite-1.subset.yaml index 0967ef424..ab16f4792 100644 --- a/test/cases/mocha/mocha/suite-1.subset.yaml +++ b/test/cases/mocha/mocha/suite-1.subset.yaml @@ -1 +1,4 @@ -{} +metadata: + recorder: + name: mocha + type: tests diff --git a/test/cases/mocha/mocha/suite-2.subset.yaml b/test/cases/mocha/mocha/suite-2.subset.yaml index 0967ef424..ab16f4792 100644 --- a/test/cases/mocha/mocha/suite-2.subset.yaml +++ b/test/cases/mocha/mocha/suite-2.subset.yaml @@ -1 +1,4 @@ -{} +metadata: + recorder: + name: mocha + type: tests diff --git a/test/cases/mocha/mocha/suite.subset.yaml b/test/cases/mocha/mocha/suite.subset.yaml index 0967ef424..ab16f4792 100644 --- a/test/cases/mocha/mocha/suite.subset.yaml +++ b/test/cases/mocha/mocha/suite.subset.yaml @@ -1 +1,4 @@ -{} +metadata: + recorder: + name: mocha + type: tests