Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
feat: Add recorder type to appmap metadata
Browse files Browse the repository at this point in the history
Fixes #235
  • Loading branch information
dividedmind committed Aug 10, 2023
1 parent 748cabb commit f7fa84b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/trace/appmap/index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion components/trace/appmap/metadata.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions components/trace/appmap/metadata.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 //
Expand Down
1 change: 1 addition & 0 deletions schema/definitions/recorder.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# NOTE: when changing this, make sure to adjust the type map in components/trace/appmap/metadata
enum:
- process
- mocha
Expand Down
5 changes: 4 additions & 1 deletion test/cases/mocha/mocha/suite-1.subset.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{}
metadata:
recorder:
name: mocha
type: tests
5 changes: 4 additions & 1 deletion test/cases/mocha/mocha/suite-2.subset.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{}
metadata:
recorder:
name: mocha
type: tests
5 changes: 4 additions & 1 deletion test/cases/mocha/mocha/suite.subset.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{}
metadata:
recorder:
name: mocha
type: tests

0 comments on commit f7fa84b

Please sign in to comment.