Merge pull request #158 from Azure/kamusta/errMsgs

Updating error messages
This commit is contained in:
kmusta 2020-01-07 14:29:08 -08:00 коммит произвёл GitHub
Родитель b73cc912e9 e59ddec7bd
Коммит 3727d0ca1e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -125,7 +125,7 @@ teardown(){
enable_count="$(echo "$output" | grep -c 'event=enabled')"
echo "Enable count=$enable_count"
[ "$enable_count" -eq 1 ]
[[ "$output" == *"this script configuration is already processed, will not run again"* ]] # not processed again
[[ "$output" == *"the script configuration has already been processed, will not run again"* ]] # not processed again
}
@test "handler command: enable - parses protected settings" {

Просмотреть файл

@ -116,7 +116,7 @@ func uninstall(ctx *log.Context, h vmextension.HandlerEnvironment, seqNum int) (
ctx = ctx.With("path", dataDir)
ctx.Log("event", "removing data dir", "path", dataDir)
if err := os.RemoveAll(dataDir); err != nil {
return "", errors.Wrap(err, "failed to delete data dir")
return "", errors.Wrap(err, "failed to delete data directory")
}
ctx.Log("event", "removed data dir")
}
@ -128,9 +128,9 @@ func enablePre(ctx *log.Context, seqNum int) error {
// exit if this sequence number (a snapshot of the configuration) is already
// processed. if not, save this sequence number before proceeding.
if shouldExit, err := checkAndSaveSeqNum(ctx, seqNum, mostRecentSequence); err != nil {
return errors.Wrap(err, "failed to process seqnum")
return errors.Wrap(err, "failed to process sequence number")
} else if shouldExit {
ctx.Log("event", "exit", "message", "this script configuration is already processed, will not run again")
ctx.Log("event", "exit", "message", "the script configuration has already been processed, will not run again")
os.Exit(0)
}
return nil
@ -197,7 +197,7 @@ func checkAndSaveSeqNum(ctx log.Logger, seq int, mrseqPath string) (shouldExit b
return true, nil
}
if err := seqnum.Set(mrseqPath, seq); err != nil {
return false, errors.Wrap(err, "failed to save the sequence number")
return false, errors.Wrap(err, "failed to save sequence number")
}
ctx.Log("event", "seqnum saved", "path", mrseqPath)
return false, nil
@ -307,7 +307,7 @@ func writeTempScript(script, dir string, skipDosToUnix bool) (string, string, er
if skipDosToUnix == false {
err = postProcessFile(cmd)
if err != nil {
return "", "", errors.Wrap(err, "failed to post process file")
return "", "", errors.Wrap(err, "failed to post-process script.sh")
}
dos2unix = 0
}
@ -319,7 +319,7 @@ func decodeScript(script string) (string, string, error) {
// scripts must be base64 encoded
s, err := base64.StdEncoding.DecodeString(script)
if err != nil {
return "", "", errors.Wrap(err, "failed to base64 decode script")
return "", "", errors.Wrap(err, "failed to decode script")
}
// scripts may be gzip'ed

Просмотреть файл

@ -40,7 +40,7 @@ func Test_checkAndSaveSeqNum_fails(t *testing.T) {
// pass in invalid seqnum format
_, err := checkAndSaveSeqNum(log.NewNopLogger(), 0, "/non/existing/dir")
require.NotNil(t, err)
require.Contains(t, err.Error(), `failed to save the sequence number`)
require.Contains(t, err.Error(), `failed to save sequence number`)
}
func Test_checkAndSaveSeqNum(t *testing.T) {

Просмотреть файл

@ -115,7 +115,7 @@ func urlToFileName(fileURL string) (string, error) {
func postProcessFile(path string) error {
ok, err := preprocess.IsTextFile(path)
if err != nil {
return errors.Wrapf(err, "error determining if script file")
return errors.Wrapf(err, "error determining if script is a text file")
}
if !ok {
return nil

Просмотреть файл

@ -36,7 +36,7 @@ func (self *blobWithMsiToken) GetRequest() (*http.Request, error) {
return nil, err
}
if msi.AccessToken == "" {
return nil, errors.New("MSI token was empty")
return nil, errors.New("MSI token is empty")
}
request, err := http.NewRequest(http.MethodGet, self.url, nil)

Просмотреть файл

@ -40,7 +40,7 @@ var (
func Download(d Downloader) (int, io.ReadCloser, error) {
req, err := d.GetRequest()
if err != nil {
return -1, nil, errors.Wrapf(err, "failed to create the request")
return -1, nil, errors.Wrapf(err, "failed to create http request")
}
resp, err := httpClient.Do(req)

Просмотреть файл

@ -23,7 +23,7 @@ func (b *badDownloader) GetRequest() (*http.Request, error) {
func TestDownload_wrapsGetRequestError(t *testing.T) {
_, _, err := download.Download(new(badDownloader))
require.NotNil(t, err)
require.EqualError(t, err, "failed to create the request: expected error")
require.EqualError(t, err, "failed to create http request: expected error")
}
func TestDownload_wrapsHTTPError(t *testing.T) {