promqltest: improve error messages when unexpected type is returned, and fix inverted expected and actual values in error message when scalar value does not match expected
@ -554,6 +554,43 @@ eval range from 0 to 5m step 5m testmetric
`,
expectedError:`error in eval testmetric (line 5): expected float value at index 0 for {__name__="testmetric"} to have timestamp 300000, but it had timestamp 0 (result has 1 float point [3 @[0]] and 1 histogram point [{count:0, sum:0} @[300000]])`,
},
"instant query with expected scalar result":{
input:`
evalinstantat1m3
3
`,
},
"instant query with unexpected scalar result":{
input:`
evalinstantat1m3
2
`,
expectedError:`error in eval 3 (line 2): expected scalar 2 but got 3`,
},
"instant query that returns a scalar but expects a vector":{
input:`
evalinstantat1m3
{}3
`,
expectedError:`error in eval 3 (line 2): expected vector or matrix result, but got scalar: 3 @[60000]`,
},
"instant query that returns a vector but expects a scalar":{
input:`
evalinstantat1mvector(3)
3
`,
expectedError:`error in eval vector(3) (line 2): expected scalar result, but got vector {} => 3 @[60000]`,
},
"range query that returns a matrix but expects a scalar":{