Skip to content

Commit

Permalink
🐛 adding test case to make sure that the scopes work
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn-hurley committed Dec 14, 2023
1 parent eaca27b commit a52a90f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func TestApplicationAnalysis(t *testing.T) {
if tc.WithDeps == true {
taskData.Mode.WithDeps = true
}
if tc.Scope != nil {
taskData.Scope = *tc.Scope
}
tc.Task.Data = taskData
assert.Should(t, RichClient.Task.Create(&tc.Task))

Expand Down
1 change: 1 addition & 0 deletions analysis/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type TC struct {
Targets []string
Labels addon.Labels
Rules addon.Rules
Scope *addon.Scope
WithDeps bool
// After-analysis assertions.
ReportContent map[string][]string
Expand Down
76 changes: 76 additions & 0 deletions analysis/tc_tackle_testapp_public_package_filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package analysis

import (
"github.com/konveyor/go-konveyor-tests/hack/addon"
"github.com/konveyor/tackle2-hub/api"
)

var TackleTestAppPackageFilter = api.Application{
Name: "Tackle Testapp public",
Repository: &api.Repository{
Kind: "git",
URL: "https://github.com/konveyor/tackle-testapp-public",
},
}

var TackleTestappPublicPackageFilter = TC{
Name: "Tackle Testapp public",
Application: TackleTestApp,
Task: Analyze,
WithDeps: false,
Labels: addon.Labels{
Included: []string{
"konveyor.io/target=cloud-readiness",
"konveyor.io/target=linux",
},
},
Identities: []api.Identity{},
Scope: &addon.Scope{
Packages: struct {
Included []string "json:\"included,omitempty\""
Excluded []string "json:\"excluded,omitempty\""
}{
Included: []string{"com.example"},
},
},
Analysis: api.Analysis{
Effort: 9,
Issues: []api.Issue{
{
Category: "mandatory",
Description: "Hardcoded IP Address\nWhen migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
Effort: 1,
RuleSet: "discovery-rules",
Rule: "hardcoded-ip-address",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/target/classes/persistence.properties",
Line: 2,
Message: "When migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
CodeSnip: "jdbc.url=jdbc:oracle:thin:@10.19.2.93:15",
},
{
File: "/addon/source/tackle-testapp-public/src/main/resources/persistence.properties",
Line: 2,
Message: "When migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
CodeSnip: "jdbc.url=jdbc:oracle:thin:@10.19.2.93:15",
},
},
},
},
},
AnalysisTags: []api.Tag{
{Name: "EJB XML", Category: api.Ref{Name: "Bean"}},
{Name: "Servlet", Category: api.Ref{Name: "HTTP"}},
{Name: "Properties", Category: api.Ref{Name: "Other"}},
{Name: "Java EE Batch", Category: api.Ref{Name: "Processing"}},
{Name: "Java EE Batch", Category: api.Ref{Name: "Java EE"}},
{Name: "Servlet", Category: api.Ref{Name: "Java EE"}},
{Name: "EJB XML", Category: api.Ref{Name: "Java EE"}},
{Name: "Properties", Category: api.Ref{Name: "Sustain"}},
{Name: "Properties", Category: api.Ref{Name: "Embedded"}},
{Name: "Java EE Batch", Category: api.Ref{Name: "Execute"}},
{Name: "EJB XML", Category: api.Ref{Name: "Connect"}},
{Name: "Servlet", Category: api.Ref{Name: "Connect"}},
},
}
1 change: 1 addition & 0 deletions analysis/test_cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package analysis
// List of applications with expected analysis outputs.
var Tier0TestCases = []TC{
TackleTestappPublicWithDeps,
TackleTestappPublicPackageFilter,
}

// Tier 1 Analysis test cases - should work.
Expand Down

0 comments on commit a52a90f

Please sign in to comment.