8363: Report arv-mount error messages as runtime_status warnings.
[arvados.git] / lib / crunchrun / logscanner_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package crunchrun
6
7 import (
8         check "gopkg.in/check.v1"
9 )
10
11 var _ = check.Suite(&logScannerSuite{})
12
13 type logScannerSuite struct {
14 }
15
16 func (s *logScannerSuite) TestCallReportFuncOnce(c *check.C) {
17         var reported []string
18         ls := logScanner{
19                 Patterns: []string{"foobar", "barbaz"},
20                 ReportFunc: func(pattern string) {
21                         reported = append(reported, pattern)
22                 },
23         }
24         ls.Write([]byte("foo\nbar\nbar"))
25         ls.Write([]byte("baz\nwaz\nqux"))
26         ls.Write([]byte("\nfoobar\n"))
27         c.Check(reported, check.DeepEquals, []string{"barbaz"})
28 }