github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/internal/daemon/handle_calls_test.go (about)

     1  // Copyright 2021 The TrueBlocks Authors. All rights reserved.
     2  // Use of this source code is governed by a license that can
     3  // be found in the LICENSE file.
     4  
     5  package daemonPkg
     6  
     7  // const output = "07807300 (  12097)- <PROG>  : Scanning 11403087 of 11854826 bloom hit false positive"
     8  
     9  // func TestProgress(t *testing.T) {
    10  // 	slices := MatchProgress(output)
    11  // 	slicesLen := len(slices)
    12  
    13  // 	if slicesLen != 4 {
    14  // 		t.Errorf("Progress regexp should have 4 matches, but got %d", slicesLen)
    15  // 	}
    16  
    17  // 	if slices[1] != "Scanning" {
    18  // 		t.Errorf("First match should be the command name, but got %s", slices[1])
    19  // 	}
    20  
    21  // 	if slices[2] != "11403087" {
    22  // 		t.Errorf("Second match should be the 'done' number, but got %s", slices[2])
    23  // 	}
    24  
    25  // 	if slices[3] != "11854826" {
    26  // 		t.Errorf("Third match should be total number, but got  %s", slices[3])
    27  // 	}
    28  // }
    29  
    30  // func TestScan ForProgress(t *testing.T) {
    31  // 	reader, writer := io.Pipe()
    32  
    33  // 	go func() {
    34  // 		fmt.Fprint(writer, output)
    35  // 		writer.Close()
    36  // 	}()
    37  
    38  // 	Scan ForProgress(reader, func(cp *Comman dProgress) {
    39  // 		if cp.Done != 11403087 {
    40  // 			t.Errorf("Done should be 11403087, but got %d", cp.Done);
    41  // 		}
    42  
    43  // 		if cp.Total != 11854826 {
    44  // 			t.Errorf("Total should be 11854826, but got %d", cp.Total);
    45  // 		}
    46  
    47  // 		if cp.Finished != false {
    48  // 			t.Errorf("Finished should be false, but got %t", cp.Finished);
    49  // 		}
    50  // 	});
    51  // }