github.com/maruel/nin@v0.0.0-20220112143044-f35891e3ce7e/cmd/nin/status_test.go (about) 1 // Copyright 2011 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "testing" 19 20 "github.com/maruel/nin" 21 ) 22 23 func TestStatusTest_StatusFormatElapsed(t *testing.T) { 24 cfg := nin.NewBuildConfig() 25 status := newStatusPrinter(&cfg) 26 27 status.BuildStarted() 28 // Before any task is done, the elapsed time must be zero. 29 if "[%/e0.000]" != status.formatProgressStatus("[%%/e%e]", 0) { 30 t.Fatal("expected equal") 31 } 32 } 33 34 func TestStatusTest_StatusFormatReplacePlaceholder(t *testing.T) { 35 cfg := nin.NewBuildConfig() 36 status := newStatusPrinter(&cfg) 37 38 if "[%/s0/t0/r0/u0/f0]" != status.formatProgressStatus("[%%/s%s/t%t/r%r/u%u/f%f]", 0) { 39 t.Fatal("expected equal") 40 } 41 }