Enhance MTProxy checker by introducing a new -probe mode deep-strict for stricter response validation. Update README and Docker documentation to clarify probing modes, exit codes, and the new MTPROXY_TDLIB_HELPER and MTPROXY_TDLIB_TIMEOUT environment variables for external helper integration. Refactor connection handling and error reporting to improve robustness and clarity in response verification.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package tdlibexec
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseStdout(t *testing.T) {
|
||||
r, err := parseStdout([]byte("noise\n{\"ok\":true,\"error\":\"\",\"exit_code\":0}\n"), nil, 42)
|
||||
if err != nil || !r.OK || r.ExitCode != 0 || r.DurationMs != 42 {
|
||||
t.Fatalf("got %+v err=%v", r, err)
|
||||
}
|
||||
r2, err := parseStdout([]byte(`{"ok":false,"error":"bad","exit_code":2}`), nil, 1)
|
||||
if err != nil || r2.OK || r2.ExitCode != 2 || r2.Error != "bad" {
|
||||
t.Fatalf("got %+v err=%v", r2, err)
|
||||
}
|
||||
if _, err := parseStdout([]byte("no json"), nil, 0); err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user