|
| 1 | +// Copyright 2026 Datafuse Labs. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +use chrono::DateTime; |
| 16 | +use databend_common_meta_app::principal as mt; |
| 17 | +use fastrace::func_name; |
| 18 | +use maplit::btreemap; |
| 19 | + |
| 20 | +use crate::common; |
| 21 | + |
| 22 | +#[test] |
| 23 | +fn test_decode_v176_task_script_sql() -> anyhow::Result<()> { |
| 24 | + let task_v176 = vec![ |
| 25 | + 8, 11, 18, 6, 116, 97, 115, 107, 95, 99, 34, 60, 66, 69, 71, 73, 78, 10, 73, 78, 83, 69, |
| 26 | + 82, 84, 32, 73, 78, 84, 79, 32, 116, 32, 86, 65, 76, 85, 69, 83, 40, 49, 41, 59, 10, 73, |
| 27 | + 78, 83, 69, 82, 84, 32, 73, 78, 84, 79, 32, 116, 32, 86, 65, 76, 85, 69, 83, 40, 50, 41, |
| 28 | + 59, 10, 69, 78, 68, 59, 50, 6, 112, 117, 98, 108, 105, 99, 114, 23, 49, 57, 55, 48, 45, 48, |
| 29 | + 49, 45, 48, 49, 32, 48, 48, 58, 48, 48, 58, 49, 49, 32, 85, 84, 67, 122, 23, 49, 57, 55, |
| 30 | + 48, 45, 48, 49, 45, 48, 49, 32, 48, 48, 58, 48, 48, 58, 49, 50, 32, 85, 84, 67, 170, 1, 2, |
| 31 | + 109, 101, 178, 1, 23, 73, 78, 83, 69, 82, 84, 32, 73, 78, 84, 79, 32, 116, 32, 86, 65, 76, |
| 32 | + 85, 69, 83, 40, 49, 41, 178, 1, 23, 73, 78, 83, 69, 82, 84, 32, 73, 78, 84, 79, 32, 116, |
| 33 | + 32, 86, 65, 76, 85, 69, 83, 40, 50, 41, 160, 6, 176, 1, 168, 6, 24, |
| 34 | + ]; |
| 35 | + |
| 36 | + let want = mt::Task { |
| 37 | + task_id: 11, |
| 38 | + task_name: "task_c".to_string(), |
| 39 | + task_sql: mt::TaskSql::Script(vec![ |
| 40 | + "INSERT INTO t VALUES(1)".to_string(), |
| 41 | + "INSERT INTO t VALUES(2)".to_string(), |
| 42 | + ]), |
| 43 | + when_condition: None, |
| 44 | + after: vec![], |
| 45 | + comment: None, |
| 46 | + owner: mt::BUILTIN_ROLE_PUBLIC.to_string(), |
| 47 | + owner_user: "me".to_string(), |
| 48 | + schedule_options: None, |
| 49 | + warehouse_options: None, |
| 50 | + next_scheduled_at: None, |
| 51 | + suspend_task_after_num_failures: None, |
| 52 | + error_integration: None, |
| 53 | + status: mt::Status::Suspended, |
| 54 | + created_at: DateTime::from_timestamp(11, 0).unwrap(), |
| 55 | + updated_at: DateTime::from_timestamp(12, 0).unwrap(), |
| 56 | + last_suspended_at: None, |
| 57 | + session_params: btreemap! {}, |
| 58 | + }; |
| 59 | + |
| 60 | + common::test_pb_from_to(func_name!(), want.clone())?; |
| 61 | + common::test_load_old(func_name!(), task_v176.as_slice(), 176, want)?; |
| 62 | + |
| 63 | + Ok(()) |
| 64 | +} |
0 commit comments