-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1024fb
commit 47fc3fb
Showing
5 changed files
with
305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
require "sorbet-runtime" | ||
require "dependabot/nuget/version" | ||
require "dependabot/ecosystem" | ||
|
||
module Dependabot | ||
module Nuget | ||
class Language < Dependabot::Ecosystem::VersionManager | ||
extend T::Sig | ||
|
||
sig { params(language: String, raw_version: String, requirement: T.nilable(Requirement)).void } | ||
def initialize(language, raw_version, requirement = nil) | ||
super(language, Version.new(raw_version), [], [], requirement) | ||
end | ||
end | ||
|
||
class CSharpLanguage < Dependabot::Ecosystem::VersionManager | ||
extend T::Sig | ||
|
||
LANGUAGE = "CSharp" | ||
TYPE = "cs" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig { params(language: String, requirement: T.nilable(Requirement)).void } | ||
def initialize(language, requirement = nil) | ||
super(language, Version.new(nil), [], [], requirement) | ||
end | ||
end | ||
|
||
class VBLanguage < Dependabot::Ecosystem::VersionManager | ||
extend T::Sig | ||
|
||
LANGUAGE = "VB" | ||
TYPE = "vb" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig { params(language: String, requirement: T.nilable(Requirement)).void } | ||
def initialize(language, requirement = nil) | ||
super(language, Version.new(nil), [], [], requirement) | ||
end | ||
end | ||
|
||
class FSharpLanguage < Dependabot::Ecosystem::VersionManager | ||
extend T::Sig | ||
|
||
LANGUAGE = "FSharp" | ||
TYPE = "fs" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig { params(language: String, requirement: T.nilable(Requirement)).void } | ||
def initialize(language, requirement = nil) | ||
super(language, Version.new(nil), [], [], requirement) | ||
end | ||
end | ||
|
||
class DotNet < Dependabot::Ecosystem::VersionManager | ||
extend T::Sig | ||
|
||
TYPE = "dotnet" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig { params(language: String, requirement: T.nilable(Requirement)).void } | ||
def initialize(language, requirement = nil) | ||
super(language, Version.new(nil), [], [], requirement) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
require "sorbet-runtime" | ||
require "dependabot/nuget/version" | ||
require "dependabot/ecosystem" | ||
require "dependabot/nuget/requirement" | ||
|
||
module Dependabot | ||
module Nuget | ||
ECOSYSTEM = "dotnet" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
class NugetPackageManager < Dependabot::Ecosystem::VersionManager | ||
extend T::Sig | ||
|
||
NAME = "nuget" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig do | ||
params( | ||
raw_version: T.nilable(String) | ||
).void | ||
end | ||
def initialize(raw_version) | ||
super( | ||
NAME, | ||
Version.new(raw_version), | ||
SUPPORTED_VERSIONS, | ||
DEPRECATED_VERSIONS | ||
) | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def deprecated? | ||
false | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def unsupported? | ||
false | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/nuget/language" | ||
require "dependabot/nuget/requirement" | ||
require "dependabot/ecosystem" | ||
require "spec_helper" | ||
|
||
RSpec.describe Dependabot::Nuget::Language do | ||
describe "#initialize" do | ||
context "when version and requirement are both strings initially" do | ||
let(:language) { Dependabot::Nuget::CSharpLanguage.new(name) } | ||
let(:name) { "cs-dotnet472" } | ||
|
||
it "sets the name correctly" do | ||
expect(language.name).to eq("cs-dotnet472") | ||
end | ||
end | ||
|
||
context "when version and requirement are both strings initially" do | ||
let(:language) { Dependabot::Nuget::VBLanguage.new(name) } | ||
let(:name) { "vb-net35" } | ||
|
||
it "sets the name correctly" do | ||
expect(language.name).to eq("vb-net35") | ||
end | ||
end | ||
|
||
context "when version and requirement are both strings initially" do | ||
let(:language) { Dependabot::Nuget::FSharpLanguage.new(name) } | ||
let(:name) { "fs-netstandard1.5" } | ||
|
||
it "sets the name correctly" do | ||
expect(language.name).to eq("fs-netstandard1.5") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/nuget/package_manager" | ||
require "dependabot/ecosystem" | ||
require "spec_helper" | ||
|
||
RSpec.describe Dependabot::Nuget::NugetPackageManager do | ||
let(:package_manager) { described_class.new("6.5.0") } | ||
|
||
describe "#initialize" do | ||
context "when version is a String" do | ||
it "sets the version correctly" do | ||
expect(package_manager.version).to eq("6.5.0") | ||
end | ||
|
||
it "sets the name correctly" do | ||
expect(package_manager.name).to eq("nuget") | ||
end | ||
end | ||
|
||
describe "#deprecated_versions" do | ||
it "returns deprecated versions" do | ||
expect(package_manager.deprecated_versions).to eq(Dependabot::Nuget::NugetPackageManager::DEPRECATED_VERSIONS) | ||
end | ||
end | ||
|
||
describe "#supported_versions" do | ||
it "returns supported versions" do | ||
expect(package_manager.supported_versions).to eq(Dependabot::Nuget::NugetPackageManager::SUPPORTED_VERSIONS) | ||
end | ||
end | ||
|
||
context "when nuget version extracted is well formed" do | ||
# If this test starts failing, you need to adjust the "nuget_version" function | ||
# to return a valid version in format x.x, x.x.x etc. examples: 3.12.5, 3.12 along with | ||
# following block | ||
version = Dependabot::SharedHelpers.run_shell_command("dotnet nuget --version").split("Command Line").last&.strip | ||
|
||
it "does not raise error" do | ||
expect(version.match(/^\d+(?:\.\d+)*$/)).to be_truthy | ||
end | ||
end | ||
end | ||
end |