@@ -319,6 +319,97 @@ void main() {
319319 expect (result, equals (ExitCode .success.code));
320320 }),
321321 );
322+
323+ test (
324+ 'unknown when non-standard license file is found' ,
325+ withRunner ((commandRunner, logger, pubUpdater, printLogs) async {
326+ File (
327+ path.join (tempDirectory.path, pubspecLockBasename),
328+ ).writeAsStringSync (_validPubspecLockContent);
329+
330+ when (
331+ () => packageConfig.packages,
332+ ).thenReturn ([veryGoodTestRunnerConfigPackage]);
333+ final licenseFilePath = path.join (
334+ tempDirectory.path,
335+ veryGoodTestRunnerConfigPackage.name,
336+ 'LICENSE' ,
337+ );
338+ File (licenseFilePath).writeAsStringSync ('''
339+ Licensed under the Apache License, Version 2.0 (the "License"); you
340+ may not use this file except in compliance with the License. You may
341+ obtain a copy of the License at
342+
343+ http://www.apache.org/licenses/LICENSE-2.0
344+
345+ Unless required by applicable law or agreed to in writing, software
346+ distributed under the License is distributed on an "AS IS" BASIS,
347+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
348+ implied. See the License for the specific language governing permissions
349+ and limitations under the License.''' );
350+
351+ when (() => logger.progress (any ())).thenReturn (progress);
352+ when (() => detectorResult.matches).thenReturn ([]);
353+
354+ final result = await commandRunner.run (
355+ [...commandArguments, tempDirectory.path],
356+ );
357+
358+ verify (
359+ () => progress.update (
360+ 'Collecting licenses from 1 out of 1 package' ,
361+ ),
362+ ).called (1 );
363+ verify (
364+ () => progress.complete (
365+ '''Retrieved 1 license from 1 package of type: unknown (1).''' ,
366+ ),
367+ ).called (1 );
368+
369+ expect (result, equals (ExitCode .success.code));
370+ }),
371+ );
372+
373+ test (
374+ 'unknown when invalid license file is found' ,
375+ withRunner ((commandRunner, logger, pubUpdater, printLogs) async {
376+ File (
377+ path.join (tempDirectory.path, pubspecLockBasename),
378+ ).writeAsStringSync (_validPubspecLockContent);
379+
380+ when (
381+ () => packageConfig.packages,
382+ ).thenReturn ([veryGoodTestRunnerConfigPackage]);
383+ final licenseFilePath = path.join (
384+ tempDirectory.path,
385+ veryGoodTestRunnerConfigPackage.name,
386+ 'LICENSE' ,
387+ );
388+ File (
389+ licenseFilePath,
390+ ).writeAsStringSync ('This is an invalid license file.' );
391+
392+ when (() => logger.progress (any ())).thenReturn (progress);
393+ when (() => detectorResult.matches).thenReturn ([]);
394+
395+ final result = await commandRunner.run (
396+ [...commandArguments, tempDirectory.path],
397+ );
398+
399+ verify (
400+ () => progress.update (
401+ 'Collecting licenses from 1 out of 1 package' ,
402+ ),
403+ ).called (1 );
404+ verify (
405+ () => progress.complete (
406+ '''Retrieved 1 license from 1 package of type: unknown (1).''' ,
407+ ),
408+ ).called (1 );
409+
410+ expect (result, equals (ExitCode .success.code));
411+ }),
412+ );
322413 },
323414 );
324415
0 commit comments