@@ -100,6 +100,52 @@ func TestShowInfoTextForSingerFiltersModulesAndOmitsStatuses(t *testing.T) {
100100 }
101101}
102102
103+ func TestShowInfoSuggestsInspectForPackageFile (t * testing.T ) {
104+ packageFile := filepath .Join (t .TempDir (), "sample package.dspk" )
105+ if err := os .WriteFile (packageFile , []byte ("not used" ), 0o644 ); err != nil {
106+ t .Fatalf ("write package file: %v" , err )
107+ }
108+
109+ var output bytes.Buffer
110+ err := ShowInfo (packageFile , t .TempDir (), "en" , false , & output )
111+ if err == nil {
112+ t .Fatalf ("ShowInfo() error = nil" )
113+ }
114+
115+ got := output .String ()
116+ if ! strings .Contains (got , "Suggestion:" ) ||
117+ ! strings .Contains (got , "dspm inspect " + packageFile ) {
118+ t .Fatalf ("output = %q" , got )
119+ }
120+ }
121+
122+ func TestShowInfoJSONDoesNotSuggestInspectForPackageFile (t * testing.T ) {
123+ packageFile := filepath .Join (t .TempDir (), "sample package.dspk" )
124+ if err := os .WriteFile (packageFile , []byte ("not used" ), 0o644 ); err != nil {
125+ t .Fatalf ("write package file: %v" , err )
126+ }
127+
128+ var output bytes.Buffer
129+ err := ShowInfo (packageFile , t .TempDir (), "en" , true , & output )
130+ if err == nil {
131+ t .Fatalf ("ShowInfo() error = nil" )
132+ }
133+
134+ got := output .String ()
135+ if strings .Contains (got , "Suggestion:" ) ||
136+ strings .Contains (got , "dspm inspect" ) {
137+ t .Fatalf ("json output should not include suggestion: %q" , got )
138+ }
139+
140+ var payload infoOutput
141+ if err := json .Unmarshal (output .Bytes (), & payload ); err != nil {
142+ t .Fatalf ("unmarshal output: %v\n %s" , err , output .String ())
143+ }
144+ if payload .OK || payload .Error == nil {
145+ t .Fatalf ("payload = %#v" , payload )
146+ }
147+ }
148+
103149func TestShowInfoJSONReportsAmbiguousVersion (t * testing.T ) {
104150 packagesDir := makeInfoTestDatabase (t )
105151
0 commit comments