github.com/apptainer/singularity@v3.1.1+incompatible/pkg/util/user-agent/agent_test.go (about)

     1  // Copyright (c) 2018, Sylabs Inc. All rights reserved.
     2  // This software is licensed under a 3-clause BSD license. Please consult the
     3  // LICENSE.md file distributed with the sources of this project regarding your
     4  // rights to use or distribute this software.
     5  
     6  package useragent
     7  
     8  import (
     9  	"regexp"
    10  	"testing"
    11  )
    12  
    13  func TestSingularityVersion(t *testing.T) {
    14  	InitValue("singularity", "3.0.0-alpha.1-303-gaed8d30-dirty")
    15  
    16  	re := regexp.MustCompile("Singularity/[[:digit:]]+(.[[:digit:]]+){2} \\(Linux [[:alnum:]]+\\) Go/[[:digit:]]+(.[[:digit:]]+){1,2}")
    17  	if !re.MatchString(Value()) {
    18  		t.Fatalf("user agent did not match regexp")
    19  	}
    20  }