From 3e9bbcd897812e64d3a356dcd5806baeec198d65 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 15:11:58 -0700 Subject: Validate version # --- spec/fixtures/schema/v2.0.json | 30 ++++++++++++++++++++++-------- spec/integration/dotnet/examples_spec.rb | 1 + spec/integration/python/pip_spec.rb | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/spec/fixtures/schema/v2.0.json b/spec/fixtures/schema/v2.0.json index 712143b..6ade7ad 100644 --- a/spec/fixtures/schema/v2.0.json +++ b/spec/fixtures/schema/v2.0.json @@ -7,7 +7,10 @@ "dependencies" ], "properties": { - "version": { "type": "string" }, + "version": { + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+$" + }, "licenses": { "type": "array", "items": { @@ -18,9 +21,15 @@ "url" ], "properties": { - "id": { "type": "string" }, - "name": { "type": "string" }, - "url": { "type": "uri" } + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "url": { + "type": "uri" + } } } }, @@ -36,9 +45,15 @@ "licenses" ], "properties": { - "name": { "type": "string" }, - "url": { "type": "uri" }, - "description": { "type": "string" }, + "name": { + "type": "string" + }, + "url": { + "type": "uri" + }, + "description": { + "type": "string" + }, "paths": { "type": "array", "items": { @@ -57,4 +72,3 @@ }, "additionalProperties": false } - diff --git a/spec/integration/dotnet/examples_spec.rb b/spec/integration/dotnet/examples_spec.rb index 43caea0..5b2a913 100644 --- a/spec/integration/dotnet/examples_spec.rb +++ b/spec/integration/dotnet/examples_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ".NET Core" do report = runner.scan(env: { 'LICENSE_FINDER_CLI_OPTS' => '--recursive' }) expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:licenses].count).not_to be_zero expect(report[:dependencies].count).not_to be_zero end diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index 5ff5f60..b092189 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -10,6 +10,7 @@ RSpec.describe "pip" do report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:version]).to start_with('2') expect(report[:dependencies].map { |x| x[:name] }).to include("sentry-sdk") expect(report[:dependencies].find { |x| x[:name] == 'sentry-sdk' }[:licenses]).to match_array(["BSD-4-Clause"]) @@ -39,6 +40,7 @@ RSpec.describe "pip" do report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:version]).to start_with('2') expect(report[:licenses]).not_to be_empty expect(report[:dependencies]).not_to be_empty -- cgit v1.2.3