Sets timestamp as default runID when environment variable is not set.
This commit is contained in:
parent
42b0ab67a0
commit
d830ccb48e
|
@ -37,18 +37,20 @@ namespace DistTestCore
|
|||
|
||||
public static string GetTestId()
|
||||
{
|
||||
return GetEnvVar("TESTID");
|
||||
return GetEnvVar("TESTID", "EnvVar-TESTID-NotSet");
|
||||
}
|
||||
|
||||
public static string GetRunId()
|
||||
{
|
||||
return GetEnvVar("RUNID");
|
||||
var now = DateTime.UtcNow;
|
||||
var defaultValue = now.ToString("yyyyMMdd-hhmmss");
|
||||
return GetEnvVar("RUNID", defaultValue);
|
||||
}
|
||||
|
||||
private static string GetEnvVar(string name)
|
||||
private static string GetEnvVar(string name, string defaultValue)
|
||||
{
|
||||
var v = Environment.GetEnvironmentVariable(name);
|
||||
if (string.IsNullOrEmpty(v)) return $"EnvVar-{name}-NotSet";
|
||||
if (string.IsNullOrEmpty(v)) return defaultValue;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue